From e1db4c1290af151b0d85c4dcad7cbb2414e0d474 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 18 Jan 2012 19:42:58 +0000 Subject: [PATCH] Avoid needless second string conversion when adding files to memory FS. Create the buffer holding the result of conversion instead of converting twice, once to only get the length of the result and the second time to get the data. Closes #13877. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70392 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/fs_mem.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/common/fs_mem.cpp b/src/common/fs_mem.cpp index e306437de4..5f96257100 100644 --- a/src/common/fs_mem.cpp +++ b/src/common/fs_mem.cpp @@ -186,13 +186,9 @@ void wxMemoryFSHandlerBase::AddFileWithMimeType(const wxString& filename, const wxString& textdata, const wxString& mimetype) { - AddFileWithMimeType - ( - filename, - static_cast(textdata.To8BitData()), - wxStrlen(static_cast(textdata.To8BitData())), - mimetype - ); + const wxCharBuffer buf(textdata.To8BitData()); + + AddFileWithMimeType(filename, buf.data(), buf.length(), mimetype); } -- 2.45.2