From 7a9180f5566f410af306f2854a32bd99315b058e Mon Sep 17 00:00:00 2001 From: Alireza Bashiri Date: Sun, 26 Nov 2017 17:31:48 +0330 Subject: [PATCH] Reduce number of calculations and iterations How? By looping just through solution projects and use its index to access both each lock project and solution project. --- cmd/dep/status.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cmd/dep/status.go b/cmd/dep/status.go index 78c5b102b5..2315bd1684 100644 --- a/cmd/dep/status.go +++ b/cmd/dep/status.go @@ -289,18 +289,19 @@ func (cmd *statusCommand) runOld(ctx *dep.Ctx, args []string, p *dep.Project, sm lockProjects := p.Lock.Projects() solutionProjects := solution.Projects() - for _, sp := range solutionProjects { - for _, lp := range lockProjects { - spr, _, _ := gps.VersionComponentStrings(sp.Version()) - lpr, _, _ := gps.VersionComponentStrings(lp.Version()) + for i := range solutionProjects { + spr, _, _ := gps.VersionComponentStrings(solutionProjects[i].Version()) + lpr, _, _ := gps.VersionComponentStrings(lockProjects[i].Version()) - if spr != lpr { - oldLockProjects = append(oldLockProjects, lp) - } + if spr != lpr { + oldLockProjects = append(oldLockProjects, lockProjects[i]) } } - // TODO: Print output + for _, oldLockProject := range oldLockProjects { + ctx.Out.Println(oldLockProject) + } + return nil }