From f09b8b192a1c27b2acb9ac2170e6ba62b14e033b Mon Sep 17 00:00:00 2001 From: Ahmed El-Sharnoby Date: Mon, 16 Oct 2023 04:07:29 +0300 Subject: [PATCH] reserve the String Length in urlDecode to avoid String Reallocations --- libraries/ESP8266WebServer/src/Parsing-impl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/ESP8266WebServer/src/Parsing-impl.h b/libraries/ESP8266WebServer/src/Parsing-impl.h index 83762a03c2..59b02c3182 100644 --- a/libraries/ESP8266WebServer/src/Parsing-impl.h +++ b/libraries/ESP8266WebServer/src/Parsing-impl.h @@ -520,6 +520,7 @@ String ESP8266WebServerTemplate::urlDecode(const String& text) char temp[] = "0x00"; unsigned int len = text.length(); unsigned int i = 0; + decoded.reserve(len - (std::count(text.begin(), text.end(), '%') * 2)); while (i < len) { char decodedChar;