summaryrefslogtreecommitdiffstats
path: root/lib/libalpm
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-02-14 03:58:35 +0100
committerDan McGee <dan@archlinux.org>2007-02-14 03:58:35 +0100
commitd871b841fb853e479482b86ec42fcfae815e4ced (patch)
treeaae445c734ee20eabcb98f24396419031e826e06 /lib/libalpm
parentc8aa0d8139156fe76fa71906cd7b8c8a11911e62 (diff)
downloadpacman-d871b841fb853e479482b86ec42fcfae815e4ced.tar.gz
pacman-d871b841fb853e479482b86ec42fcfae815e4ced.tar.xz
Slightly optimized to remove duplicate strcmp operation.
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/conflict.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index ffc9dc68..27558565 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -220,18 +220,25 @@ static alpm_list_t *chk_fileconflicts(alpm_list_t *filesA, alpm_list_t *filesB)
while(pA && pB) {
const char *strA = pA->data;
const char *strB = pB->data;
+ /* skip directories, we don't care about dir conflicts */
if(strA[strlen(strA)-1] == '/') {
pA = pA->next;
} else if(strB[strlen(strB)-1] == '/') {
pB = pB->next;
- } else if(strcmp(strA, strB) == -1) {
- pA = pA->next;
- } else if(strcmp(strB, strA) == -1) {
- pB = pB->next;
} else {
- ret = alpm_list_add(ret, strdup(strA));
- pA = pA->next;
- pB = pB->next;
+ int cmp = strcmp(strA, strB);
+ if(cmp < 0) {
+ /* item only in filesA, ignore it */
+ pA = pA->next;
+ } else if(cmp > 0) {
+ /* item only in filesB, ignore it */
+ pB = pB->next;
+ } else {
+ /* item in both, record it */
+ ret = alpm_list_add(ret, strdup(strA));
+ pA = pA->next;
+ pB = pB->next;
+ }
}
}
for(alpm_list_t *i = ret; i; i = i->next) {