Remove block sort algorithm and per-seed tests

This commit is contained in:
Ian Gulliver
2026-02-23 22:32:46 -08:00
parent 7dbc3e8088
commit 49f0cdc290
3 changed files with 1 additions and 47 deletions

View File

@@ -19,8 +19,6 @@ type Block struct {
Track string `json:"track,omitempty"` Track string `json:"track,omitempty"`
Name string `json:"name"` Name string `json:"name"`
Loop bool `json:"loop,omitempty"` Loop bool `json:"loop,omitempty"`
weight uint64
} }
type Trigger struct { type Trigger struct {

View File

@@ -1,7 +1,6 @@
package main package main
import ( import (
"cmp"
"fmt" "fmt"
"io" "io"
"slices" "slices"
@@ -201,7 +200,7 @@ func BuildTimelineDebug(show *Show, debugW io.Writer) (Timeline, error) {
tl.Blocks[block.ID] = block tl.Blocks[block.ID] = block
} }
sortedBlocks := tl.sortBlocks() sortedBlocks := tl.show.Blocks
endChains := map[string]bool{} endChains := map[string]bool{}
for _, trigger := range show.Triggers { for _, trigger := range show.Triggers {
@@ -225,38 +224,6 @@ func BuildTimelineDebug(show *Show, debugW io.Writer) (Timeline, error) {
return tl, nil return tl, nil
} }
func (tl *Timeline) sortBlocks() []*Block {
cueIdx := 0
for _, b := range tl.show.Blocks {
if b.Type == "cue" {
b.weight = uint64(cueIdx+1) << 32
cueIdx++
} else {
b.weight = 0
}
}
changed := true
for changed {
changed = false
for _, t := range tl.show.Triggers {
src := tl.Blocks[t.Source.Block]
for _, target := range t.Targets {
dst := tl.Blocks[target.Block]
if dst.weight <= src.weight {
dst.weight = src.weight + 1
changed = true
}
}
}
}
sorted := slices.Clone(tl.show.Blocks)
slices.SortFunc(sorted, func(a, b *Block) int {
return cmp.Compare(a.weight, b.weight)
})
return sorted
}
func (tl *Timeline) addConstraint(kind constraintKind, a, b *TimelineCell) { func (tl *Timeline) addConstraint(kind constraintKind, a, b *TimelineCell) {
tl.constraints = append(tl.constraints, constraint{kind: kind, a: a, b: b}) tl.constraints = append(tl.constraints, constraint{kind: kind, a: a, b: b})

View File

@@ -26,17 +26,6 @@ func TestBuildTimelineFromMockShow(t *testing.T) {
t.Logf("tracks=%d blocks=%d", len(tl.Tracks), len(tl.Blocks)) t.Logf("tracks=%d blocks=%d", len(tl.Tracks), len(tl.Blocks))
} }
func TestBuildTimelineSeed11(t *testing.T) {
show := GenerateMockShow(11, 5, 20, 4, 5)
if err := show.Validate(); err != nil {
t.Fatalf("validate: %v", err)
}
_, err := BuildTimeline(show)
if err != nil {
t.Fatalf("BuildTimeline failed: %v", err)
}
}
func BenchmarkBuildTimeline(b *testing.B) { func BenchmarkBuildTimeline(b *testing.B) {
show := GenerateMockShow(42, 5, 20, 4, 5) show := GenerateMockShow(42, 5, 20, 4, 5)
if err := show.Validate(); err != nil { if err := show.Validate(); err != nil {