diff options
| author | Pieter Wuille <[email protected]> | 2017-06-05 12:17:40 -0700 |
|---|---|---|
| committer | Pieter Wuille <[email protected]> | 2017-06-09 13:23:20 -0700 |
| commit | e241a63c23239adf54fe69baf02f3159222b71e4 (patch) | |
| tree | 71f0784ba648f1c0d2e7ab73df7c1de9c776c02e /src/prevector.h | |
| parent | Merge #10471: Denote functions CNode::GetRecvVersion() and CNode::GetRefCount... (diff) | |
| download | discoin-e241a63c23239adf54fe69baf02f3159222b71e4.tar.xz discoin-e241a63c23239adf54fe69baf02f3159222b71e4.zip | |
Clarify prevector::erase and avoid swap-to-clear
Diffstat (limited to 'src/prevector.h')
| -rw-r--r-- | src/prevector.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/prevector.h b/src/prevector.h index 177d81383..dc17e7ce4 100644 --- a/src/prevector.h +++ b/src/prevector.h @@ -387,6 +387,12 @@ public: } iterator erase(iterator first, iterator last) { + // Erase is not allowed to the change the object's capacity. That means + // that when starting with an indirectly allocated prevector with + // size and capacity > N, the result may be a still indirectly allocated + // prevector with size <= N and capacity > N. A shrink_to_fit() call is + // necessary to switch to the (more efficient) directly allocated + // representation (with capacity N and size <= N). iterator p = first; char* endp = (char*)&(*end()); if (!std::is_trivially_destructible<T>::value) { |