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:
Ben Boeckel 2014-02-10 01:39:33 -05:00
parent bb1c41a085
commit 5554910ec2
1 changed files with 3 additions and 2 deletions

View File

@ -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;
}