diff --git a/include/wx/string.h b/include/wx/string.h index 81f564801e..e07f559ba1 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -1368,7 +1368,7 @@ public: size_type capacity() const { return m_impl.capacity(); } void reserve(size_t sz) { m_impl.reserve(sz); } - void shrink_to_fit() { Shrink(); } + void shrink_to_fit() { m_impl.shrink_to_fit(); } void resize(size_t nSize, wxUniChar ch = wxT('\0')) { @@ -2241,8 +2241,7 @@ public: // only works if the data of this string is not shared bool Alloc(size_t nLen) { reserve(nLen); return capacity() >= nLen; } // minimize the string's memory - // only works if the data of this string is not shared - bool Shrink(); + bool Shrink() { shrink_to_fit(); return true; } // wxWidgets version 1 compatibility functions diff --git a/interface/wx/string.h b/interface/wx/string.h index 3aecdc6596..e872d25a54 100644 --- a/interface/wx/string.h +++ b/interface/wx/string.h @@ -1422,7 +1422,7 @@ public: wxStringBuffer and wxStringBufferLength classes may be very useful when working with some external API which requires the caller to provide a writable buffer. - See also the reserve() and resize() STL-like functions. + See also the reserve(), resize() and shrink_to_fit() STL-like functions. */ ///@{ @@ -1468,6 +1468,9 @@ public: /** Minimizes the string's memory. + Please note that this method does the same thing as the standard + shrink_to_fit() one and shouldn't be used in new code. + This can be useful after a call to Alloc() if too much memory were preallocated. diff --git a/src/common/string.cpp b/src/common/string.cpp index 2c8c91b754..600ad6a943 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -514,14 +514,6 @@ const char *wxString::AsChar(const wxMBConv& conv) const return m_convertedToChar.m_str; } -// shrink to minimal size (releasing extra memory) -bool wxString::Shrink() -{ - wxString tmp(begin(), end()); - swap(tmp); - return true; -} - // --------------------------------------------------------------------------- // data access // ---------------------------------------------------------------------------