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.
This commit is contained in:
parent
7547ef23ee
commit
ba7def0ef6
@ -408,12 +408,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void swap(prevector<N, T, Size, Diff>& other) {
|
void swap(prevector<N, T, Size, Diff>& other) {
|
||||||
if (_size & other._size & 1) {
|
std::swap(_union, other._union);
|
||||||
std::swap(_union.capacity, other._union.capacity);
|
|
||||||
std::swap(_union.indirect, other._union.indirect);
|
|
||||||
} else {
|
|
||||||
std::swap(_union, other._union);
|
|
||||||
}
|
|
||||||
std::swap(_size, other._size);
|
std::swap(_size, other._size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user