From: Mikko Rasa Date: Fri, 9 Dec 2022 22:27:01 +0000 (+0200) Subject: Reserve space for strings before appending characters X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=21c6efbcc6ed534849a5b4d41d9a4bd3a2fb0d8a;p=libs%2Fnet.git Reserve space for strings before appending characters --- diff --git a/source/http/utils.cpp b/source/http/utils.cpp index 2f13576..8662c2e 100644 --- a/source/http/utils.cpp +++ b/source/http/utils.cpp @@ -31,6 +31,7 @@ namespace Http { string urlencode(const string &str, EncodeLevel level) { string result; + result.reserve(str.size()); for(char c: str) { if(is_reserved(c, level)) @@ -44,6 +45,7 @@ string urlencode(const string &str, EncodeLevel level) string urlencode_plus(const string &str, EncodeLevel level) { string result; + result.reserve(str.size()); for(char c: str) { if(c==' ')