replace std::string::substr() with operations that do not allocate memory

Modify the original string instead of creating a new copy with substr() when it
is not used for anything else afterwards.
This commit is contained in:
Rolf Eike Beer
2020-03-21 12:51:46 +01:00
parent 77616f4681
commit ef778d77e0
11 changed files with 31 additions and 23 deletions
+1 -1
View File
@@ -103,7 +103,7 @@ int cmCPackNSISGenerator::PackageFiles()
componentName = fileN.substr(0, slash);
// Strip off the component part of the path.
fileN = fileN.substr(slash + 1);
fileN.erase(0, slash + 1);
}
}
std::replace(fileN.begin(), fileN.end(), '/', '\\');
+1 -1
View File
@@ -85,7 +85,7 @@ int cpackDefinitionArgument(const char* argument, const char* cValue,
return 0;
}
std::string key = value.substr(0, pos);
value = value.substr(pos + 1);
value.erase(0, pos + 1);
def->Map[key] = value;
cmCPack_Log(def->Log, cmCPackLog::LOG_DEBUG,
"Set CPack variable: " << key << " to \"" << value << "\""