internal/pkg: skip duplicate early
All checks were successful
Test / Create distribution (push) Successful in 1m0s
Test / Sandbox (push) Successful in 2m43s
Test / Hakurei (push) Successful in 3m50s
Test / ShareFS (push) Successful in 4m1s
Test / Hpkg (push) Successful in 4m44s
Test / Sandbox (race detector) (push) Successful in 5m9s
Test / Hakurei (race detector) (push) Successful in 5m55s
Test / Flake checks (push) Successful in 1m44s

This significantly increases IR generation performance.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-02-07 17:11:41 +09:00
parent 31a8cc9b5c
commit ffd2f979fb

View File

@@ -254,15 +254,16 @@ func (c *Cache) encodeAll(
a Artifact, a Artifact,
encoded map[Artifact]struct{}, encoded map[Artifact]struct{},
) (err error) { ) (err error) {
if _, ok := encoded[a]; ok {
return
}
for _, d := range a.Dependencies() { for _, d := range a.Dependencies() {
if err = c.encodeAll(w, d, encoded); err != nil { if err = c.encodeAll(w, d, encoded); err != nil {
return return
} }
} }
if _, ok := encoded[a]; ok {
return
}
encoded[a] = struct{}{} encoded[a] = struct{}{}
return c.Encode(w, a) return c.Encode(w, a)
} }