From d5ece3c4b5e109f65f5d3315c43239dd87bb2c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C5=91rinc?= Date: Sat, 9 Mar 2024 13:31:40 +0100 Subject: [PATCH] Reserve hrp memory in Decode and LocateErrors --- src/bech32.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bech32.cpp b/src/bech32.cpp index c3c4ca8006f..fafd2007a68 100644 --- a/src/bech32.cpp +++ b/src/bech32.cpp @@ -393,6 +393,7 @@ DecodeResult Decode(const std::string& str, CharLimit limit) { values[i] = rev; } std::string hrp; + hrp.reserve(pos); for (size_t i = 0; i < pos; ++i) { hrp += LowerCase(str[i]); } @@ -425,6 +426,7 @@ std::pair> LocateErrors(const std::string& str, Ch } std::string hrp; + hrp.reserve(pos); for (size_t i = 0; i < pos; ++i) { hrp += LowerCase(str[i]); }