File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -387,6 +387,12 @@ class prevector {
387
387
}
388
388
389
389
iterator erase (iterator first, iterator last) {
390
+ // Erase is not allowed to the change the object's capacity. That means
391
+ // that when starting with an indirectly allocated prevector with
392
+ // size and capacity > N, the result may be a still indirectly allocated
393
+ // prevector with size <= N and capacity > N. A shrink_to_fit() call is
394
+ // necessary to switch to the (more efficient) directly allocated
395
+ // representation (with capacity N and size <= N).
390
396
iterator p = first;
391
397
char * endp = (char *)&(*end ());
392
398
if (!std::is_trivially_destructible<T>::value) {
Original file line number Diff line number Diff line change @@ -648,8 +648,9 @@ class CScript : public CScriptBase
648
648
649
649
void clear ()
650
650
{
651
- // The default std::vector::clear() does not release memory.
652
- CScriptBase ().swap (*this );
651
+ // The default prevector::clear() does not release memory
652
+ CScriptBase::clear ();
653
+ shrink_to_fit ();
653
654
}
654
655
};
655
656
You can’t perform that action at this time.
0 commit comments