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 {
387387 }
388388
389389 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).
390396 iterator p = first;
391397 char * endp = (char *)&(*end ());
392398 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
642642
643643 void clear ()
644644 {
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 ();
647648 }
648649};
649650
You can’t perform that action at this time.
0 commit comments