From 530862cd6becefa2cd8b9cc7c8caa6cb534aa5ff Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Sun, 6 Dec 2026 10:27:32 +1300 Subject: [PATCH] perf(relations): track ids as visited when queued rather than when popped --- go/cmd/relations/alias.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/go/cmd/relations/alias.go b/go/cmd/relations/alias.go index f2e5db61e83..2f372416650 100644 --- a/go/cmd/relations/alias.go +++ b/go/cmd/relations/alias.go @@ -120,18 +120,20 @@ func createAliasGroup(ctx context.Context, cl *datastore.Client, vulnIDs []strin // The returned slice contains the vuln ID itself, all the IDs from the vuln's raw aliases, all the IDs of vulns that have // the current vuln as an alias, and repeat for every vuln encountered. func computeAliases(vulnID string, visited map[string]struct{}, vulnAliases map[string]map[string]struct{}) []string { + if _, ok := visited[vulnID]; ok { + return nil + } + + visited[vulnID] = struct{}{} toVisit := []string{vulnID} var vulnIDs []string for len(toVisit) > 0 { vulnID, toVisit = toVisit[0], toVisit[1:] - if _, ok := visited[vulnID]; ok { - continue - } - visited[vulnID] = struct{}{} vulnIDs = append(vulnIDs, vulnID) for aliasID := range vulnAliases[vulnID] { - if !slices.Contains(toVisit, aliasID) { + if _, ok := visited[aliasID]; !ok { + visited[aliasID] = struct{}{} toVisit = append(toVisit, aliasID) } }