src/list.c

changeset 1466
a58c65d31342
parent 1463
e228b5bde7f6
--- a/src/list.c	Sat Nov 01 19:48:50 2025 +0100
+++ b/src/list.c	Sun Nov 02 18:04:35 2025 +0100
@@ -866,39 +866,7 @@
         cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data) {
     if (clone_allocator == NULL) clone_allocator = cxDefaultAllocator;
 
-    // first, remove existing items from dst when needed
-    if (cxCollectionSorted(dst) && cxCollectionSorted(subtrahend)) {
-        CxIterator dst_iter = cxListIterator(dst);
-        CxIterator sub_iter = cxListIterator(subtrahend);
-        while (cxIteratorValid(dst_iter) && cxIteratorValid(sub_iter)) {
-            void *dst_elem = cxIteratorCurrent(dst_iter);
-            void *sub_elem = cxIteratorCurrent(sub_iter);
-            cx_compare_func cmp = subtrahend->collection.cmpfunc;
-            int d = cmp(sub_elem, dst_elem);
-            if (d == 0) {
-                // is contained, so remove it
-                cxIteratorFlagRemoval(dst_iter);
-                cxIteratorNext(dst_iter);
-            } else if (d < 0) {
-                // subtrahend is smaller than the dst element,
-                // check the next element in the subtrahend
-                cxIteratorNext(sub_iter);
-            } else {
-                // subtrahend is larger than the dst element,
-                // check the next dst element
-                cxIteratorNext(dst_iter);
-            }
-        }
-    } else {
-        CxIterator dst_iter = cxListIterator(dst);
-        cx_foreach(void *, elem, dst_iter) {
-            if (cxListContains(subtrahend, elem)) {
-                cxIteratorFlagRemoval(dst_iter);
-            }
-        }
-    }
-
-    // now perform the difference calculation
+    // optimize for sorted collections
     if (cxCollectionSorted(minuend) && cxCollectionSorted(subtrahend)) {
         bool dst_was_empty = cxCollectionSize(dst) == 0;
 

mercurial