diff options
author | Florian Jacomme <florian@jacomme.fr> | 2018-05-01 14:17:31 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-05-22 14:56:24 (GMT) |
commit | b1a05d6c762ceb6dbf47126a7ddcedadb45e02f5 (patch) | |
tree | 61dd702ca38457507a1b0416e61a1aae350ca90d /Source/cmMacroCommand.cxx | |
parent | 743f24bac68010c0157dc0349958e09ed1784f5f (diff) | |
download | CMake-b1a05d6c762ceb6dbf47126a7ddcedadb45e02f5.zip CMake-b1a05d6c762ceb6dbf47126a7ddcedadb45e02f5.tar.gz CMake-b1a05d6c762ceb6dbf47126a7ddcedadb45e02f5.tar.bz2 |
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.
Diffstat (limited to 'Source/cmMacroCommand.cxx')
-rw-r--r-- | Source/cmMacroCommand.cxx | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index 6f4b930..23d93a3 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -161,9 +161,9 @@ bool cmMacroFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, { // record commands until we hit the ENDMACRO // at the ENDMACRO call we shift gears and start looking for invocations - if (!cmSystemTools::Strucmp(lff.Name.c_str(), "macro")) { + if (lff.Name.Lower == "macro") { this->Depth++; - } else if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endmacro")) { + } else if (lff.Name.Lower == "endmacro") { // if this is the endmacro for this macro then execute if (!this->Depth) { mf.AppendProperty("MACROS", this->Args[0].c_str()); @@ -191,7 +191,7 @@ bool cmMacroFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, bool cmMacroFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) { - if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endmacro")) { + if (lff.Name.Lower == "endmacro") { std::vector<std::string> expandedArguments; mf.ExpandArguments(lff.Arguments, expandedArguments, this->GetStartingContext().FilePath.c_str()); |