diff --git a/primitiveCollections/src/main/java/org/lucares/collections/IntList.java b/primitiveCollections/src/main/java/org/lucares/collections/IntList.java index af0e586..7a7e375 100644 --- a/primitiveCollections/src/main/java/org/lucares/collections/IntList.java +++ b/primitiveCollections/src/main/java/org/lucares/collections/IntList.java @@ -1062,14 +1062,14 @@ public final class IntList implements Serializable, Cloneable { } private static IntList unionUnsorted(final IntList a, final IntList b) { - // TODO use a more efficient algorithm. Especially the removeIf is too - // expensive, because of all the method calls - final IntList result; - result = new IntList(a.size() + b.size()); - result.addAll(a); - result.addAll(b); - result.sort(); - result.removeIf((value, index) -> index > 0 && result.get(index) == result.get(index - 1)); - return result; + // TODO use a more efficient algorithm. The sort operations make this 10 times + // slower than unionSorted + + final IntList aSorted = new IntList(a); + aSorted.parallelSort(); + final IntList bSorted = new IntList(b); + bSorted.parallelSort(); + + return unionSorted(aSorted, bSorted); } }