From 21c6efbcc6ed534849a5b4d41d9a4bd3a2fb0d8a Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 10 Dec 2022 00:27:01 +0200 Subject: [PATCH] Reserve space for strings before appending characters --- source/http/utils.cpp | 2 ++ 1 file changed, 2 insertions(+) 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==' ') -- 2.45.2