Speedup comparing lists if they happen to be in the same order

This commit is contained in:
morganamilo 2024-02-03 13:16:24 +00:00 committed by Allan McRae
parent 62095d916b
commit 7a43c6fee0

View file

@ -525,6 +525,15 @@ int SYMEXPORT alpm_list_cmp_unsorted(const alpm_list_t *left,
return 0;
}
/* faster comparison for if the lists happen to be in the same order */
while(left && fn(left->data, right->data) == 0) {
left = left->next;
right = right->next;
}
if(!left) {
return 1;
}
matched = calloc(alpm_list_count(right), sizeof(int));
for(l = left; l; l = l->next) {