mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-23 08:18:51 -05:00
Slightly optimized to remove duplicate strcmp operation.
This commit is contained in:
parent
c8aa0d8139
commit
d871b841fb
@ -220,20 +220,27 @@ static alpm_list_t *chk_fileconflicts(alpm_list_t *filesA, alpm_list_t *filesB)
|
|||||||
while(pA && pB) {
|
while(pA && pB) {
|
||||||
const char *strA = pA->data;
|
const char *strA = pA->data;
|
||||||
const char *strB = pB->data;
|
const char *strB = pB->data;
|
||||||
|
/* skip directories, we don't care about dir conflicts */
|
||||||
if(strA[strlen(strA)-1] == '/') {
|
if(strA[strlen(strA)-1] == '/') {
|
||||||
pA = pA->next;
|
pA = pA->next;
|
||||||
} else if(strB[strlen(strB)-1] == '/') {
|
} else if(strB[strlen(strB)-1] == '/') {
|
||||||
pB = pB->next;
|
pB = pB->next;
|
||||||
} else if(strcmp(strA, strB) == -1) {
|
} else {
|
||||||
|
int cmp = strcmp(strA, strB);
|
||||||
|
if(cmp < 0) {
|
||||||
|
/* item only in filesA, ignore it */
|
||||||
pA = pA->next;
|
pA = pA->next;
|
||||||
} else if(strcmp(strB, strA) == -1) {
|
} else if(cmp > 0) {
|
||||||
|
/* item only in filesB, ignore it */
|
||||||
pB = pB->next;
|
pB = pB->next;
|
||||||
} else {
|
} else {
|
||||||
|
/* item in both, record it */
|
||||||
ret = alpm_list_add(ret, strdup(strA));
|
ret = alpm_list_add(ret, strdup(strA));
|
||||||
pA = pA->next;
|
pA = pA->next;
|
||||||
pB = pB->next;
|
pB = pB->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for(alpm_list_t *i = ret; i; i = i->next) {
|
for(alpm_list_t *i = ret; i; i = i->next) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "found conflict = %s", i->data);
|
_alpm_log(PM_LOG_DEBUG, "found conflict = %s", i->data);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user