forked from security/hakurei
internal/pkg: skip duplicate early
This significantly increases IR generation performance. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user