diff options
author | Kaz Wesley <keziahw@gmail.com> | 2016-04-14 09:26:32 -0700 |
---|---|---|
committer | Kaz Wesley <keziahw@gmail.com> | 2016-04-16 08:05:11 -0700 |
commit | a7af72a697a8decab364792230153f114be3919c (patch) | |
tree | 086ebada01f780d23b4785212b50bad679ddb1af | |
parent | 4ed41a2b611dfd328fe6f72312d6c596650f03f8 (diff) |
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.
-rw-r--r-- | src/prevector.h | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/src/prevector.h b/src/prevector.h index 16b2f8dca7..a0e1e140b4 100644 --- a/src/prevector.h +++ b/src/prevector.h @@ -412,12 +412,7 @@ public: } void swap(prevector<N, T, Size, Diff>& other) { - if (_size & other._size & 1) { - std::swap(_union.capacity, other._union.capacity); - std::swap(_union.indirect, other._union.indirect); - } else { - std::swap(_union, other._union); - } + std::swap(_union, other._union); std::swap(_size, other._size); } |