@@ -941,38 +941,31 @@ pool_buildflavorcmp(Pool *pool, Solvable *s1, Solvable *s2)
941941
942942void intersect_selection (Pool * pool , Id dep , Queue * prev )
943943{
944- Queue tmp , res ;
944+ Queue tmp ;
945+ int i = 0 , j = 0 , isectidx = 0 ;
946+
945947 queue_init (& tmp );
946- // could use queue init buffer as optimization
947- queue_init (& res );
948948
949949 Id * pp , p ;
950950 pp = pool_whatprovides_ptr (pool , dep );
951951 while ((p = * pp ++ ) != 0 )
952- {
953952 queue_push (& tmp , p );
954- }
955953
956- int i = 0 , j = 0 ;
957954 // set intersection, assuming sorted arrays
958- if (prev )
959- {
960- while (i < prev -> count && j < tmp .count ) {
961- if (prev -> elements [i ] < tmp .elements [j ])
962- i ++ ;
963- else if (tmp .elements [j ] < prev -> elements [i ])
964- j ++ ;
965- else /* if arr1[i] == arr2[j] */
966- {
967- queue_push (& res , tmp .elements [j ]);
968- i ++ ;
969- j ++ ;
970- }
971- }
972- }
955+ while (i < prev -> count && j < tmp .count )
956+ if (prev -> elements [i ] < tmp .elements [j ])
957+ i ++ ;
958+ else if (tmp .elements [j ] < prev -> elements [i ])
959+ j ++ ;
960+ else
961+ {
962+ if (isectidx != i )
963+ prev -> elements [isectidx ] = prev -> elements [i ];
964+ i ++ , j ++ , isectidx ++ ;
965+ }
966+
967+ prev -> count = isectidx ;
973968 queue_free (& tmp );
974- queue_free (prev );
975- prev = & res ;
976969}
977970
978971int check_deps_unequal (Pool * pool , Queue * q1 , Queue * q2 , Id name )
@@ -992,37 +985,31 @@ int check_deps_unequal(Pool* pool, Queue* q1, Queue* q2, Id name)
992985Id best_matching (Pool * pool , Queue * q , Id name , int * all_have_trackfeatures )
993986{
994987 int first = 1 ;
995- Id p , * pp ;
988+ Id dep , p , * pp ;
996989
997990 Queue selection ;
998991 queue_init (& selection );
999992
1000- Id elem ;
1001-
1002993 for (int i = 0 ; i < q -> count ; ++ i )
1003994 {
1004- elem = q -> elements [i ];
1005- if (!ISRELDEP (elem ) || GETRELDEP (pool , elem )-> name != name ) continue ;
995+ dep = q -> elements [i ];
996+ if (!ISRELDEP (dep ) || GETRELDEP (pool , dep )-> name != name ) continue ;
1006997
1007998 if (first )
1008999 {
1009- pp = pool_whatprovides_ptr (pool , elem );
1000+ pp = pool_whatprovides_ptr (pool , dep );
10101001 while ((p = * pp ++ ) != 0 )
1011- {
10121002 queue_push (& selection , p );
1013- }
10141003 first = 0 ;
10151004 }
10161005 else
1017- {
1018- intersect_selection (pool , elem , & selection );
1019- }
1006+ intersect_selection (pool , dep , & selection );
10201007 }
10211008
10221009 if (selection .count == 0 )
10231010 return 0 ;
10241011
1025- Solvable * best = pool_id2solvable (pool , selection .elements [0 ]), * stmp ;
1012+ Solvable * stmp , * best = pool_id2solvable (pool , selection .elements [0 ]);
10261013 int cmp ;
10271014
10281015 * all_have_trackfeatures = 1 ;
@@ -1083,23 +1070,28 @@ int conda_compare_dependencies(Pool *pool, Solvable *s1, Solvable *s2)
10831070 continue ;
10841071 }
10851072
1086- int aht_1 , aht_2 ;
1073+ int aht_1 , aht_2 ; // all have track features check
10871074 Id b1 = best_matching (pool , & q1 , rd1 -> name , & aht_1 );
10881075 Id b2 = best_matching (pool , & q2 , rd1 -> name , & aht_2 );
10891076
1090- // one of both is not solvable
1091- // add random (high) id here
1077+ // one of both or both is not solvable...
1078+ // ignoring this case for now
10921079 if (b1 == 0 || b2 == 0 )
10931080 continue ;
10941081 // comparison_result += (b1 - b2);
10951082
1096- // if one has deps with track features, and the other does not, downweight
1097- // the one with track features
1083+ // if one has deps with track features, and the other does not,
1084+ // downweight the one with track features
10981085 if (aht_1 != aht_2 )
10991086 comparison_result += (aht_1 - aht_2 ) * 100 ;
11001087
11011088 comparison_result += pool_evrcmp (pool , b2 , b1 , 0 );
11021089 }
1090+
1091+ queue_free (& q1 );
1092+ queue_free (& q2 );
1093+ queue_free (& seen );
1094+
11031095 return comparison_result ;
11041096}
11051097
0 commit comments