Sun, 26 Oct 2025 16:23:36 +0100
cxListDifference() sets the sorted flag if it can guarantee that
relates to #745
| src/list.c | file | annotate | diff | comparison | revisions |
--- 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) {