solver_samerule -> solver_rulecmp
authorMichael Schroeder <mls@suse.de>
Tue, 20 Nov 2012 14:40:56 +0000 (15:40 +0100)
committerMichael Schroeder <mls@suse.de>
Tue, 20 Nov 2012 14:40:56 +0000 (15:40 +0100)
src/libsolv.ver
src/rules.c
src/rules.h
src/solver.c
src/transaction.c

index 6262777..4296b1a 100644 (file)
@@ -342,7 +342,7 @@ SOLV_1.0 {
                solver_ruleclass;
                solver_ruleinfo;
                solver_ruleliterals;
-               solver_samerule;
+               solver_rulecmp;
                solver_select2str;
                solver_set_flag;
                solver_solution_count;
index 88ab0a1..537d320 100644 (file)
@@ -122,7 +122,7 @@ unifyrules_sortcmp(const void *ap, const void *bp, void *dp)
 }
 
 int
-solver_samerule(Solver *solv, Rule *r1, Rule *r2)
+solver_rulecmp(Solver *solv, Rule *r1, Rule *r2)
 {
   return unifyrules_sortcmp(r1, r2, solv->pool);
 }
index ea56aa7..d42b22b 100644 (file)
@@ -97,7 +97,7 @@ solver_enablerule(struct _Solver *solv, Rule *r)
 
 extern Rule *solver_addrule(struct _Solver *solv, Id p, Id d);
 extern void solver_unifyrules(struct _Solver *solv);
-extern int solver_samerule(struct _Solver *solv, Rule *r1, Rule *r2);
+extern int solver_rulecmp(struct _Solver *solv, Rule *r1, Rule *r2);
 
 /* rpm rules */
 extern void solver_addrpmrulesforsolvable(struct _Solver *solv, Solvable *s, Map *m);
index 9880442..a1dec92 100644 (file)
@@ -3000,7 +3000,7 @@ solver_solve(Solver *solv, Queue *job)
              assert(solv->dupmap_all && !sr->p);
              continue;
            }
-         if (!solver_samerule(solv, r, sr))
+         if (!solver_rulecmp(solv, r, sr))
            memset(sr, 0, sizeof(*sr));         /* delete unneeded feature rule */
          else
            solver_disablerule(solv, sr);       /* disable feature rule */
index 816e125..31c4637 100644 (file)
@@ -575,8 +575,7 @@ create_transaction_info(Transaction *trans, Queue *decisionq)
            continue;
          if (pool->obsoleteusescolors && !pool_colormatch(pool, s, s2))
            continue;
-         queue_push(ti, p);
-         queue_push(ti, p2);
+         queue_push2(ti, p, p2);
        }
       if (s->obsoletes && !noobs)
        {
@@ -592,24 +591,27 @@ create_transaction_info(Transaction *trans, Queue *decisionq)
                    continue;
                  if (pool->obsoleteusescolors && !pool_colormatch(pool, s, s2))
                    continue;
-                 queue_push(ti, p);
-                 queue_push(ti, p2);
+                 queue_push2(ti, p, p2);
                }
            }
        }
     }
-  solv_sort(ti->elements, ti->count / 2, 2 * sizeof(Id), obsq_sortcmp, pool);
-  /* now unify */
-  for (i = j = 0; i < ti->count; i += 2)
+  if (ti->count > 2)
     {
-      if (j && ti->elements[i] == ti->elements[j - 2] && ti->elements[i + 1] == ti->elements[j - 1])
-       continue;
-      ti->elements[j++] = ti->elements[i];
-      ti->elements[j++] = ti->elements[i + 1];
+      /* sort and unify */
+      solv_sort(ti->elements, ti->count / 2, 2 * sizeof(Id), obsq_sortcmp, pool);
+      for (i = j = 2; i < ti->count; i += 2)
+       {
+         if (ti->elements[i] == ti->elements[j - 2] && ti->elements[i + 1] == ti->elements[j - 1])
+           continue;
+         ti->elements[j++] = ti->elements[i];
+         ti->elements[j++] = ti->elements[i + 1];
+       }
+      queue_truncate(ti, j);
     }
-  ti->count = j;
 
   /* create transaction_installed helper */
+  /*   entry > 0: exactly one obsoleter, entry < 0: multiple obsoleters, -entry is "best" */
   trans->transaction_installed = solv_calloc(installed->end - installed->start, sizeof(Id));
   for (i = 0; i < ti->count; i += 2)
     {
@@ -618,7 +620,7 @@ create_transaction_info(Transaction *trans, Queue *decisionq)
        trans->transaction_installed[j] = ti->elements[i];
       else
        {
-         /* more than one package obsoletes us. compare */
+         /* more than one package obsoletes us. compare to find "best" */
          Id q[4];
          if (trans->transaction_installed[j] > 0)
            trans->transaction_installed[j] = -trans->transaction_installed[j];