@@ -168,17 +168,20 @@ func (a *rootAnalyzer) DeriveManifestAndLock(dir string, pr gps.ProjectRoot) (gp
168
168
func (a * rootAnalyzer ) FinalizeRootManifestAndLock (m * dep.Manifest , l * dep.Lock , ol dep.Lock ) {
169
169
// Iterate through the new projects in solved lock and add them to manifest
170
170
// if they are direct deps and log feedback for all the new projects.
171
- sl := gps .SortedLockedProjects (l .Projects ())
172
- sol := gps .SortedLockedProjects (ol .Projects ())
173
- for i , y := range sl {
171
+ //
172
+ // IDEA: Make a lookup map of ProjectRoot ->projects in the old lock
173
+ // use that data structure to simplify these loops
174
+ olLookup := make (map [gps.ProjectRoot ]gps.LockedProject )
175
+ for _ , op := range ol .Projects () {
176
+ olLookup [op .Ident ().ProjectRoot ] = op
177
+ }
178
+ for _ , y := range l .Projects () {
174
179
var f * fb.ConstraintFeedback
175
180
pr := y .Ident ().ProjectRoot
176
- if i < len (sol ) {
177
- op := sol [i ]
178
- if same := y .Ident ().Eq (op .Ident ()); same {
179
- if diff := gps .DiffProjects (y , op ); diff != nil {
180
- fmt .Printf ("Some changes: \n Imported: %v\n Revised: %v\n Diff: %v\n " , y , op , diff )
181
- }
181
+
182
+ if op , ok := olLookup [pr ]; ok {
183
+ if diff := gps .DiffProjects (y , op ); diff != nil {
184
+ fmt .Printf ("Some changes: \n Imported: %v\n Revised: %v\n Diff: %v\n " , y , op , diff )
182
185
}
183
186
}
184
187
// New constraints: in new lock and dir dep but not in manifest
0 commit comments