mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-18 00:02:21 +08:00
Revise implementation of case-insensitive command names
Store both the as-written and lower-case command names and use the latter to avoid case-insensitive string comparisons. With this I obtain 2-6% speed increase (on Windows) for the configure step with no significant changes in memory usage. A case-insensitive comparison is a lot slower than just calling `==` because the operator will use things like memcmp, so prefer the latter. The `cmSystemTools::LowerCase` function allocates a new string each time it is called, so before this change we were allocating in: * cmMakefile::Configure two times for each function (to look for `cmake_minimum_required` and `project`) * cmMakefile::ExecuteCommand twice by function by calling cmState::GetCommand and copying the name Now we are only allocating once by function instead of four.
This commit is contained in:

committed by
Brad King

parent
743f24bac6
commit
b1a05d6c76
@@ -9,7 +9,6 @@
|
||||
#include "cmMakefile.h"
|
||||
#include "cmPolicies.h"
|
||||
#include "cmState.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
// define the class for function commands
|
||||
class cmFunctionHelperCommand : public cmCommand
|
||||
@@ -128,9 +127,9 @@ bool cmFunctionFunctionBlocker::IsFunctionBlocked(
|
||||
{
|
||||
// record commands until we hit the ENDFUNCTION
|
||||
// at the ENDFUNCTION call we shift gears and start looking for invocations
|
||||
if (!cmSystemTools::Strucmp(lff.Name.c_str(), "function")) {
|
||||
if (lff.Name.Lower == "function") {
|
||||
this->Depth++;
|
||||
} else if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endfunction")) {
|
||||
} else if (lff.Name.Lower == "endfunction") {
|
||||
// if this is the endfunction for this function then execute
|
||||
if (!this->Depth) {
|
||||
// create a new command and add it to cmake
|
||||
@@ -157,7 +156,7 @@ bool cmFunctionFunctionBlocker::IsFunctionBlocked(
|
||||
bool cmFunctionFunctionBlocker::ShouldRemove(const cmListFileFunction& lff,
|
||||
cmMakefile& mf)
|
||||
{
|
||||
if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endfunction")) {
|
||||
if (lff.Name.Lower == "endfunction") {
|
||||
std::vector<std::string> expandedArguments;
|
||||
mf.ExpandArguments(lff.Arguments, expandedArguments,
|
||||
this->GetStartingContext().FilePath.c_str());
|
||||
|
Reference in New Issue
Block a user