From d2c67ae0a42bb5c09b192a2a42cb96e38cc4b151 Mon Sep 17 00:00:00 2001 From: Jo Date: Tue, 25 Feb 2025 17:15:34 +0100 Subject: [PATCH] fix(yay): fix minor performance and safety issue (#2581) --- pkg/dep/dep_graph.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/pkg/dep/dep_graph.go b/pkg/dep/dep_graph.go index f3a403b6..6c8809b5 100644 --- a/pkg/dep/dep_graph.go +++ b/pkg/dep/dep_graph.go @@ -165,7 +165,6 @@ func (g *Grapher) GraphFromTargets(ctx context.Context, } if pkg != nil { g.GraphSyncPkg(ctx, graph, pkg, nil) - continue } @@ -537,12 +536,13 @@ func (g *Grapher) findDepsFromAUR(ctx context.Context, } // remove packages that don't satisfy the dependency - for i := 0; i < len(aurPkgs); i++ { - if !satisfiesAur(depString, &aurPkgs[i]) { - aurPkgs = append(aurPkgs[:i], aurPkgs[i+1:]...) - i-- + satisfyingPkgs := make([]aurc.Pkg, 0, len(aurPkgs)) + for i := range aurPkgs { + if satisfiesAur(depString, &aurPkgs[i]) { + satisfyingPkgs = append(satisfyingPkgs, aurPkgs[i]) } } + aurPkgs = satisfyingPkgs if len(aurPkgs) == 0 { g.logger.Errorln(gotext.Get("No AUR package found for"), " ", depString) @@ -813,10 +813,11 @@ func makeAURPKGFromSrcinfo(dbExecutor db.Executor, srcInfo *gosrc.Srcinfo) ([]*a archStringToString(alpmArch, srcInfo.Package.Provides)...), Replaces: append(archStringToString(alpmArch, pkg.Replaces), archStringToString(alpmArch, srcInfo.Package.Replaces)...), - OptDepends: []string{}, - Groups: pkg.Groups, - License: pkg.License, - Keywords: []string{}, + OptDepends: append(archStringToString(alpmArch, pkg.OptDepends), + archStringToString(alpmArch, srcInfo.Package.OptDepends)...), + Groups: pkg.Groups, + License: pkg.License, + Keywords: []string{}, }) }