From bd3dd1a43d8309695d082961f30c07981bab7298 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Fri, 20 Feb 2026 17:10:02 -0700 Subject: [PATCH] Extract enforceConstraints from assignRows --- cmd/qrunproxy/timeline.go | 49 ++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/cmd/qrunproxy/timeline.go b/cmd/qrunproxy/timeline.go index 000fd16..3709465 100644 --- a/cmd/qrunproxy/timeline.go +++ b/cmd/qrunproxy/timeline.go @@ -225,34 +225,35 @@ func (tl *Timeline) buildConstraints() { func (tl *Timeline) assignRows() { for { - found := false - for _, c := range tl.constraints { - switch c.kind { - case "same_row": - if c.a.row < c.b.row { - tl.insertGap(c.a.track, c.a.row) - found = true - } else if c.b.row < c.a.row { - tl.insertGap(c.b.track, c.b.row) - found = true - } - case "next_row": - if c.b.row <= c.a.row { - tl.insertGap(c.b.track, c.b.row) - found = true - } - } - if found { - break - } + if tl.enforceConstraints() { + continue } - if !found { - found = tl.enforceExclusives() + if tl.enforceExclusives() { + continue } - if !found { - break + break + } +} + +func (tl *Timeline) enforceConstraints() bool { + for _, c := range tl.constraints { + switch c.kind { + case "same_row": + if c.a.row < c.b.row { + tl.insertGap(c.a.track, c.a.row) + return true + } else if c.b.row < c.a.row { + tl.insertGap(c.b.track, c.b.row) + return true + } + case "next_row": + if c.b.row <= c.a.row { + tl.insertGap(c.b.track, c.b.row) + return true + } } } + return false } func (tl *Timeline) enforceExclusives() bool {