X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a3622daa901777a33969d8bc04e2d62dee14d164..d1427b705318677afe28b1291867f6930c8823a7:/src/common/string.cpp diff --git a/src/common/string.cpp b/src/common/string.cpp index ac64abaeb6..1273610fb6 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -34,6 +34,7 @@ #ifndef WX_PRECOMP #include "wx/defs.h" #include "wx/string.h" +#include #endif #include @@ -46,7 +47,8 @@ // allocating extra space for each string consumes more memory but speeds up // the concatenation operations (nLen is the current string's length) -#define EXTRA_ALLOC 16 +// NB: EXTRA_ALLOC must be >= 0! +#define EXTRA_ALLOC (19 - nLen % 16) // --------------------------------------------------------------------------- // static class variables definition @@ -1089,9 +1091,9 @@ wxArrayString::wxArrayString(const wxArrayString& src) // assignment operator wxArrayString& wxArrayString::operator=(const wxArrayString& src) { - Clear(); + if ( m_nSize > 0 ) + Clear(); - m_nSize = 0; if ( src.m_nCount > ARRAY_DEFAULT_INITIAL_SIZE ) Alloc(src.m_nCount); @@ -1230,7 +1232,7 @@ void wxArrayString::Insert(const wxString& str, size_t nIndex) { wxASSERT( str.GetStringData()->IsValid() ); - wxCHECK_RET( nIndex <= m_nCount, "bad index in wxArrayString::Insert" ); + wxCHECK_RET( nIndex <= m_nCount, ("bad index in wxArrayString::Insert") ); Grow(); @@ -1246,7 +1248,7 @@ void wxArrayString::Insert(const wxString& str, size_t nIndex) // removes item from array (by index) void wxArrayString::Remove(size_t nIndex) { - wxCHECK_RET( nIndex <= m_nCount, "bad index in wxArrayString::Remove" ); + wxCHECK_RET( nIndex <= m_nCount, _("bad index in wxArrayString::Remove") ); // release our lock Item(nIndex).GetStringData()->Unlock(); @@ -1262,7 +1264,7 @@ void wxArrayString::Remove(const char *sz) int iIndex = Index(sz); wxCHECK_RET( iIndex != NOT_FOUND, - "removing inexistent element in wxArrayString::Remove" ); + _("removing inexistent element in wxArrayString::Remove") ); Remove((size_t)iIndex); }