From 2df80c6473a8f6558806dfb2515517e6edb266ee Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Tue, 8 Mar 2022 20:07:55 -0500 Subject: [PATCH] Add some more reserves for string funcs --- common/string_utils.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/string_utils.cpp b/common/string_utils.cpp index a60232e492..27593d4d4c 100644 --- a/common/string_utils.cpp +++ b/common/string_utils.cpp @@ -50,6 +50,8 @@ wxString ConvertToNewOverbarNotation( const wxString& aOldStr ) if( aOldStr == "~" ) return aOldStr; + newStr.reserve( aOldStr.length() ); + for( wxString::const_iterator chIt = aOldStr.begin(); chIt != aOldStr.end(); ++chIt ) { if( *chIt == '~' ) @@ -327,6 +329,8 @@ wxString TitleCaps( const wxString& aString ) wxStringSplit( aString, words, ' ' ); + result.reserve( aString.length() ); + for( const wxString& word : words ) { if( !result.IsEmpty() ) @@ -445,6 +449,8 @@ std::string EscapedUTF8( const wxString& aString ) std::string ret; + ret.reserve( utf8.length() + 2 ); + ret += '"'; for( std::string::const_iterator it = utf8.begin(); it!=utf8.end(); ++it ) @@ -476,6 +482,8 @@ wxString EscapeHTML( const wxString& aString ) { wxString converted; + converted.reserve( aString.length() ); + for( wxUniChar c : aString ) { if( c == '\"' )