mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-05 05:39:57 -05:00
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:
@@ -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(), '/', '\\');
|
||||
|
||||
@@ -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 << "\""
|
||||
|
||||
Reference in New Issue
Block a user