Add wxVector::shrink_to_fit() for C++11 compatibility

Also use this for wxArray::Shrink() implementation as it's more
efficient than the old swap-based implementation which requires an extra
memory allocation instead of really shrinking the existing one.
This commit is contained in:
Vadim Zeitlin
2017-11-19 22:09:37 +01:00
parent 9e714fdb5e
commit 53443b5370
3 changed files with 42 additions and 0 deletions

View File

@@ -375,6 +375,12 @@ public:
return m_capacity;
}
void shrink_to_fit()
{
m_values = Ops::Realloc(m_values, m_size, m_size);
m_capacity = m_size;
}
bool empty() const
{
return size() == 0;