]> git.saurik.com Git - wxWidgets.git/commitdiff
[ 1123256 ] wxString operator+ pre-allocates buffer then throws it away ---- and...
authorRyan Norton <wxprojects@comcast.net>
Tue, 15 Feb 2005 19:12:36 +0000 (19:12 +0000)
committerRyan Norton <wxprojects@comcast.net>
Tue, 15 Feb 2005 19:12:36 +0000 (19:12 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32081 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/string.cpp

index b9e30160aa606bdb8ac09986cc96d61489c8b57e..d448b4b306203ad4468b3614f4eca01739524eae 100644 (file)
@@ -326,7 +326,7 @@ wxStringBase& wxStringBase::append(size_t n, wxChar ch)
 {
     size_type len = length();
 
-    if ( !CopyBeforeWrite() || !Alloc(len + n) ) {
+    if ( !Alloc(len + n) || !CopyBeforeWrite() ) {
       wxFAIL_MSG( _T("out of memory in wxStringBase::append") );
     }
     GetStringData()->nDataLength = len + n;
@@ -445,7 +445,7 @@ wxStringBase& wxStringBase::insert(size_t nPos, const wxChar *sz, size_t n)
   if ( n == npos ) n = wxStrlen(sz);
   if ( n == 0 ) return *this;
 
-  if ( !CopyBeforeWrite() || !Alloc(length() + n) ) {
+  if ( !Alloc(length() + n) || !CopyBeforeWrite() ) {
     wxFAIL_MSG( _T("out of memory in wxStringBase::insert") );
   }
 
@@ -1225,7 +1225,7 @@ wxString operator+(const wxString& str, const wxChar *psz)
   if ( !s.Alloc(wxStrlen(psz) + str.Len()) ) {
     wxFAIL_MSG( _T("out of memory in wxString::operator+") );
   }
-  s = str;
+  s += str;
   s += psz;
 
   return s;