Compile each path's steps, leaves and cover once at link, deleting pathCover, coverPath and pathLeaves

This commit is contained in:
2026-09-30 17:09:50 +02:00
committed by Lillem4n
parent 0f58784a1b
commit 6b9755b3ef
10 changed files with 149 additions and 103 deletions
+23
View File
@@ -93,9 +93,32 @@ func linkTemplate(folder []string, path, category string, t *template, root map[
return fmt.Errorf("%s: %w", path, err)
}
t.link, t.compiled = link, compiled
compileArms(t)
return nil
}
func compileArms(t *template) {
if r := t.link.readsColumn; r != nil {
compileArm(t, &r.a)
}
for i := range t.compiled.ops {
o := &t.compiled.ops[i]
for j := range o.operands {
compileArm(t, &o.operands[j])
}
for j := range o.arms {
compileArm(t, &o.arms[j])
}
}
}
func compileArm(t *template, a *arm) {
if head := t.head(a.head); head != nil {
w := compilePath(head, a.tail)
a.steps, a.leaves, a.cover = w.steps, w.leaves, w.cover
}
}
// resolveLink binds every reference t reads, refusing one to t's own category, and keys
// t's draw group by that category, so a name is local to it:
// docs/decisions.md#a-category-never-references-itself-and-a-records-fences-run-at-load