Use std::string_view to avoid redundant std::string construction

This commit is contained in:
elsid 2022-08-02 23:57:09 +02:00
parent caf971b979
commit ba69146ced
No known key found for this signature in database
GPG key ID: 4DE04C198CBA7625
4 changed files with 10 additions and 9 deletions

View file

@ -36,8 +36,8 @@ namespace Interpreter{
if(eschar == '%' || eschar == '^')
{
retval << text.substr(start, i - start);
std::string temp = Misc::StringUtils::lowerCase(text.substr(i+1, 100));
std::string temp = Misc::StringUtils::lowerCase(std::string_view(text).substr(i + 1, 100));
bool found = false;
try
{
@ -170,10 +170,10 @@ namespace Interpreter{
sort(globals.begin(), globals.end(), longerStr);
}
for(unsigned int j = 0; j < globals.size(); j++){
if(globals[j].length() > temp.length()){ // Just in case there's a global with a huuuge name
temp = Misc::StringUtils::lowerCase(text.substr(i+1, globals[j].length()));
}
for(unsigned int j = 0; j < globals.size(); j++)
{
if (globals[j].length() > temp.length()) // Just in case there's a global with a huuuge name
temp = Misc::StringUtils::lowerCase(std::string_view(text).substr(i + 1, globals[j].length()));
found = check(temp, globals[j], &i, &start);
if(found){