From: Vadim Zeitlin Date: Sun, 30 Sep 2012 22:28:31 +0000 (+0000) Subject: Small optimization of wxFFile::ReadAll(): avoid extra string copy. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/3bc69d48db7cd54db9c67dedfe82cc13890bcf71?ds=inline Small optimization of wxFFile::ReadAll(): avoid extra string copy. 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 --- diff --git a/src/common/ffile.cpp b/src/common/ffile.cpp index 5212066a63..ae19669204 100644 --- a/src/common/ffile.cpp +++ b/src/common/ffile.cpp @@ -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; }