From b0c04b4fb3cd08142fda2d1e9c19561076763205 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 238b7b72d3..0d432aa69f 100644 --- a/libraries/ESP8266WebServer/src/Parsing-impl.h +++ b/libraries/ESP8266WebServer/src/Parsing-impl.h @@ -514,6 +514,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;