diff -r 022fbd4bc057 -r 19379743e5a0 src/list.c --- a/src/list.c Sun Apr 09 19:37:00 2023 +0200 +++ b/src/list.c Sun Apr 09 20:00:44 2023 +0200 @@ -219,11 +219,11 @@ CxList const *list, CxList const *other ) { - if (list->cl->compare == other->cl->compare) { - // same compare function, lists are compatible - return list->cl->compare(list, other); - } else { - // different compare functions, use iterator + if ((list->store_pointer ^ other->store_pointer) || + ((list->climpl == NULL) ^ (other->climpl != NULL)) || + ((list->climpl != NULL ? list->climpl->compare : list->cl->compare) != + (other->climpl != NULL ? other->climpl->compare : other->cl->compare))) { + // lists are definitely different - cannot use internal compare function if (list->size == other->size) { CxIterator left = cxListIterator(list); CxIterator right = cxListIterator(other); @@ -241,6 +241,9 @@ } else { return list->size < other->size ? -1 : 1; } + } else { + // lists are compatible + return list->cl->compare(list, other); } }