From cfa593d0ea0c2fd6bc42951f50e8b314cd74561a Mon Sep 17 00:00:00 2001 From: Mahmoud Abumandour Date: Tue, 15 Apr 2025 21:42:12 -0700 Subject: [PATCH] isa_parser: don't append one char at a time in strtolower This avoids potential re-alloations as it allocates the result string upfront. --- disasm/isa_parser.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/disasm/isa_parser.cc b/disasm/isa_parser.cc index 4708b298..61fd1644 100644 --- a/disasm/isa_parser.cc +++ b/disasm/isa_parser.cc @@ -1,11 +1,12 @@ #include "isa_parser.h" +#include #include static std::string strtolower(const char* str) { - std::string res; - for (const char *r = str; *r; r++) - res += std::tolower(*r); + std::string res(str); + for (char &c : res) + c = std::tolower(c); return res; }