diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-02-07 17:11:41 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-02-07 17:11:41 +0900 |
| commit | ffd2f979fb620e72611ba718ac9f64f2c59f89a1 (patch) | |
| tree | d94cbfad62de5db5ea1c5790ac2ee710f6bbf814 | |
| parent | 31a8cc9b5cfe6056c9f19e15426794110ebaf874 (diff) | |
internal/pkg: skip duplicate early
This significantly increases IR generation performance.
Signed-off-by: Ophestra <cat@gensokyo.uk>
| -rw-r--r-- | internal/pkg/ir.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/internal/pkg/ir.go b/internal/pkg/ir.go index f40cd874..58dcbfee 100644 --- a/internal/pkg/ir.go +++ b/internal/pkg/ir.go @@ -254,15 +254,16 @@ func (c *Cache) encodeAll( a Artifact, encoded map[Artifact]struct{}, ) (err error) { + if _, ok := encoded[a]; ok { + return + } + for _, d := range a.Dependencies() { if err = c.encodeAll(w, d, encoded); err != nil { return } } - if _, ok := encoded[a]; ok { - return - } encoded[a] = struct{}{} return c.Encode(w, a) } |
