# HG changeset patch # User Mike Becker # Date 1761492216 -3600 # Node ID 808688e304d540b239d533fc7caee0c95c5b3f70 # Parent b6fc5b1d5c5d09e3570628073b8fb72368779a31 cxListDifference() sets the sorted flag if it can guarantee that relates to #745 diff -r b6fc5b1d5c5d -r 808688e304d5 src/list.c --- a/src/list.c Sun Oct 26 16:16:43 2025 +0100 +++ b/src/list.c Sun Oct 26 16:23:36 2025 +0100 @@ -900,6 +900,8 @@ // now perform the difference calculation if (cxCollectionSorted(minuend) && cxCollectionSorted(subtrahend)) { + bool dst_was_empty = cxCollectionSize(dst) == 0; + CxIterator min_iter = cxListIterator(minuend); CxIterator sub_iter = cxListIterator(subtrahend); while (cxIteratorValid(min_iter)) { @@ -938,6 +940,9 @@ cxIteratorNext(min_iter); } } + + // if dst was empty, it is now guaranteed to be sorted + dst->collection.sorted = dst_was_empty; } else { CxIterator min_iter = cxListIterator(minuend); cx_foreach(void *, elem, min_iter) {