Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit 7a9180f

Browse files
author
Alireza Bashiri
committed
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.
1 parent 24afc01 commit 7a9180f

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

cmd/dep/status.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -289,18 +289,19 @@ func (cmd *statusCommand) runOld(ctx *dep.Ctx, args []string, p *dep.Project, sm
289289
lockProjects := p.Lock.Projects()
290290
solutionProjects := solution.Projects()
291291

292-
for _, sp := range solutionProjects {
293-
for _, lp := range lockProjects {
294-
spr, _, _ := gps.VersionComponentStrings(sp.Version())
295-
lpr, _, _ := gps.VersionComponentStrings(lp.Version())
292+
for i := range solutionProjects {
293+
spr, _, _ := gps.VersionComponentStrings(solutionProjects[i].Version())
294+
lpr, _, _ := gps.VersionComponentStrings(lockProjects[i].Version())
296295

297-
if spr != lpr {
298-
oldLockProjects = append(oldLockProjects, lp)
299-
}
296+
if spr != lpr {
297+
oldLockProjects = append(oldLockProjects, lockProjects[i])
300298
}
301299
}
302300

303-
// TODO: Print output
301+
for _, oldLockProject := range oldLockProjects {
302+
ctx.Out.Println(oldLockProject)
303+
}
304+
304305
return nil
305306
}
306307

0 commit comments

Comments
 (0)