mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 08:20:18 -06:00
cmSourceFileLocation: Avoid string allocation in extension checking
The substr call was causing excess allocations. Swap the cheaper character check to be before the longer string comparison, now using the prefix checking function.
This commit is contained in:
@@ -183,8 +183,9 @@ cmSourceFileLocation
|
||||
// Check if loc's name could possibly be extended to our name by
|
||||
// adding an extension.
|
||||
if(!(this->Name.size() > loc.Name.size() &&
|
||||
this->Name.substr(0, loc.Name.size()) == loc.Name &&
|
||||
this->Name[loc.Name.size()] == '.'))
|
||||
this->Name[loc.Name.size()] == '.' &&
|
||||
cmHasLiteralPrefixImpl(this->Name.c_str(),
|
||||
loc.Name.c_str(), loc.Name.size())))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user