Skip to content

Commit d5ece3c

Browse files
committed
Reserve hrp memory in Decode and LocateErrors
1 parent ff7d205 commit d5ece3c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/bech32.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ DecodeResult Decode(const std::string& str, CharLimit limit) {
393393
values[i] = rev;
394394
}
395395
std::string hrp;
396+
hrp.reserve(pos);
396397
for (size_t i = 0; i < pos; ++i) {
397398
hrp += LowerCase(str[i]);
398399
}
@@ -425,6 +426,7 @@ std::pair<std::string, std::vector<int>> LocateErrors(const std::string& str, Ch
425426
}
426427

427428
std::string hrp;
429+
hrp.reserve(pos);
428430
for (size_t i = 0; i < pos; ++i) {
429431
hrp += LowerCase(str[i]);
430432
}

0 commit comments

Comments
 (0)