]> git.saurik.com Git - wxWidgets.git/commitdiff
Small optimization of wxFFile::ReadAll(): avoid extra string copy.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 30 Sep 2012 22:28:31 +0000 (22:28 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 30 Sep 2012 22:28:31 +0000 (22:28 +0000)
Use swap() to move the newly created string into its destination instead of
copying it there. This can be relatively important as the string represents an
entire file contents here and so could be quite long.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72597 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/ffile.cpp

index 5212066a637bb7a9eb41c7f384ecc1efaf19886c..ae196692041bcc9726fc2c5f530a178e5e394841 100644 (file)
@@ -117,7 +117,9 @@ bool wxFFile::ReadAll(wxString *str, const wxMBConv& conv)
     }
 
     buf.data()[length] = 0;
-    *str = wxString(buf, conv);
+
+    wxString strTmp(buf, conv);
+    str->swap(strTmp);
 
     return true;
 }