From a7e831cfab716bacc858bc9f25c83540a0bbd0f9 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Fri, 20 Feb 2026 16:58:42 -0700 Subject: [PATCH] Pre-compute end-chains-same-track set, remove per-block trigger scan --- cmd/qrunproxy/timeline.go | 41 ++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/cmd/qrunproxy/timeline.go b/cmd/qrunproxy/timeline.go index d3334f7..62da1c8 100644 --- a/cmd/qrunproxy/timeline.go +++ b/cmd/qrunproxy/timeline.go @@ -126,7 +126,20 @@ func BuildTimeline(show Show) (Timeline, error) { tl.Blocks[block.ID] = block } - tl.buildCells() + endChains := map[string]bool{} + for _, trigger := range show.Triggers { + if trigger.Source.Signal != "END" { + continue + } + srcTrack := tl.Blocks[trigger.Source.Block].Track + for _, target := range trigger.Targets { + if target.Hook == "START" && tl.Blocks[target.Block].Track == srcTrack { + endChains[trigger.Source.Block] = true + } + } + } + + tl.buildCells(endChains) tl.buildConstraints() tl.assignRows() @@ -173,22 +186,7 @@ func (tl *Timeline) findCell(blockID, event string) *TimelineCell { panic("cell not found: " + blockID + " " + event) } -func (tl *Timeline) endChainsSameTrack(blockID string) bool { - trackID := tl.Blocks[blockID].Track - for _, trigger := range tl.show.Triggers { - if trigger.Source.Block != blockID || trigger.Source.Signal != "END" { - continue - } - for _, target := range trigger.Targets { - if target.Hook == "START" && tl.Blocks[target.Block].Track == trackID { - return true - } - } - } - return false -} - -func (tl *Timeline) buildCells() { +func (tl *Timeline) buildCells(endChains map[string]bool) { for _, sb := range tl.show.Blocks { block := tl.Blocks[sb.ID] track := tl.trackIdx[block.Track] @@ -200,7 +198,7 @@ func (tl *Timeline) buildCells() { cells = getBlockCells(block) } track.appendCells(cells...) - if block.Type != "cue" && !tl.endChainsSameTrack(block.ID) { + if block.Type != "cue" && !endChains[block.ID] { track.appendCells(&TimelineCell{IsGap: true, IsBreak: true}) } } @@ -211,7 +209,6 @@ func (tl *Timeline) buildConstraints() { source := tl.findCell(trigger.Source.Block, trigger.Source.Signal) group := exclusiveGroup{members: []*TimelineCell{source}} - hasCrossTrack := false for _, target := range trigger.Targets { t := tl.findCell(target.Block, target.Hook) @@ -219,14 +216,10 @@ func (tl *Timeline) buildConstraints() { tl.addConstraint("next_row", source, t) } else { tl.addConstraint("same_row", source, t) - hasCrossTrack = true + source.IsSignal = true } group.members = append(group.members, t) } - - if hasCrossTrack { - source.IsSignal = true - } tl.exclusives = append(tl.exclusives, group) } }