summaryrefslogtreecommitdiffstats
path: root/Source/cmSourceFileLocation.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2014-02-10 06:39:33 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2014-04-29 01:43:09 (GMT)
commit5554910ec2573282a85e61736e96f48e5f550066 (patch)
tree215b43a4e2f524e5afe1fcee30463b66daece403 /Source/cmSourceFileLocation.cxx
parentbb1c41a085c6eb9296bf701ea7633f715a06f6e1 (diff)
downloadCMake-5554910ec2573282a85e61736e96f48e5f550066.zip
CMake-5554910ec2573282a85e61736e96f48e5f550066.tar.gz
CMake-5554910ec2573282a85e61736e96f48e5f550066.tar.bz2
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.
Diffstat (limited to 'Source/cmSourceFileLocation.cxx')
-rw-r--r--Source/cmSourceFileLocation.cxx5
1 files changed, 3 insertions, 2 deletions
diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx
index c050202..9c0b2c5 100644
--- a/Source/cmSourceFileLocation.cxx
+++ b/Source/cmSourceFileLocation.cxx
@@ -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;
}