Skip to content

Commit a7af72a

Browse files
committed
prevector::swap: fix (unreached) data corruption
swap was using an incorrect condition to determine when to apply an optimization (not swapping the full direct[] when swapping two indirect prevectors). Rather than correct the optimization I'm removing it for simplicity. Removing this optimization minutely improves performance in the typical (currently only) usage of member swap(), which is swapping with a freshly value-initialized object.
1 parent 4ed41a2 commit a7af72a

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/prevector.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -412,12 +412,7 @@ class prevector {
412412
}
413413

414414
void swap(prevector<N, T, Size, Diff>& other) {
415-
if (_size & other._size & 1) {
416-
std::swap(_union.capacity, other._union.capacity);
417-
std::swap(_union.indirect, other._union.indirect);
418-
} else {
419-
std::swap(_union, other._union);
420-
}
415+
std::swap(_union, other._union);
421416
std::swap(_size, other._size);
422417
}
423418

0 commit comments

Comments
 (0)