Browse Source

isa_parser: don't append one char at a time in strtolower

This avoids potential re-alloations as it allocates the result string
upfront.
pull/1961/head
Mahmoud Abumandour 12 months ago
parent
commit
cfa593d0ea
  1. 7
      disasm/isa_parser.cc

7
disasm/isa_parser.cc

@ -1,11 +1,12 @@
#include "isa_parser.h"
#include <cstring>
#include <stdexcept>
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;
}

Loading…
Cancel
Save