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 @@ -642,8 +642,9 @@ class CScript : public CScriptBase
642
642
643
643
void clear ()
644
644
{
645
- // The default std::vector::clear() does not release memory.
646
- CScriptBase ().swap (*this );
645
+ // The default prevector::clear() does not release memory
646
+ CScriptBase::clear ();
647
+ shrink_to_fit ();
647
648
}
648
649
};
649
650
You can’t perform that action at this time.
0 commit comments