diff options
author | Michael Schroeder <mls@suse.de> | 2012-11-20 15:40:56 +0100 |
---|---|---|
committer | Michael Schroeder <mls@suse.de> | 2012-11-20 15:40:56 +0100 |
commit | 78bc17cb1b658e723e7855c0cc645c68f2971a6e (patch) | |
tree | 17862d2b193d616c6f51af092b77bdbb712e4351 | |
parent | a68828a07dbcb2d61545dcb2bb73c9abdcd55d24 (diff) | |
download | libsolv-78bc17cb1b658e723e7855c0cc645c68f2971a6e.tar.gz libsolv-78bc17cb1b658e723e7855c0cc645c68f2971a6e.tar.bz2 libsolv-78bc17cb1b658e723e7855c0cc645c68f2971a6e.zip |
solver_samerule -> solver_rulecmp
-rw-r--r-- | src/libsolv.ver | 2 | ||||
-rw-r--r-- | src/rules.c | 2 | ||||
-rw-r--r-- | src/rules.h | 2 | ||||
-rw-r--r-- | src/solver.c | 2 | ||||
-rw-r--r-- | src/transaction.c | 28 |
5 files changed, 19 insertions, 17 deletions
diff --git a/src/libsolv.ver b/src/libsolv.ver index 6262777..4296b1a 100644 --- a/src/libsolv.ver +++ b/src/libsolv.ver @@ -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; diff --git a/src/rules.c b/src/rules.c index 88ab0a1..537d320 100644 --- a/src/rules.c +++ b/src/rules.c @@ -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); } diff --git a/src/rules.h b/src/rules.h index ea56aa7..d42b22b 100644 --- a/src/rules.h +++ b/src/rules.h @@ -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); diff --git a/src/solver.c b/src/solver.c index 9880442..a1dec92 100644 --- a/src/solver.c +++ b/src/solver.c @@ -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 */ diff --git a/src/transaction.c b/src/transaction.c index 816e125..31c4637 100644 --- a/src/transaction.c +++ b/src/transaction.c @@ -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]; |