make unionUnsorted 5-10% faster for lists with 100k elements
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user