[Cmake-commits] CMake branch, next, updated. v3.5.1-689-g641bc68
Brad King
brad.king at kitware.com
Tue Mar 29 10:33:55 EDT 2016
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, next has been updated
via 641bc68e9a1e79d7df654f5768223238da9c820b (commit)
via 5c324294ce8488537c68085b187c9fe2a51664c4 (commit)
from 83a4aec25e404a2975fcc06bf181ec1bf4941bd2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=641bc68e9a1e79d7df654f5768223238da9c820b
commit 641bc68e9a1e79d7df654f5768223238da9c820b
Merge: 83a4aec 5c32429
Author: Brad King <brad.king at kitware.com>
AuthorDate: Tue Mar 29 10:33:54 2016 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Mar 29 10:33:54 2016 -0400
Merge topic 'preallocate-condition-keywords' into next
5c324294 cmConditionEvaluator: Pre-allocate keyword strings
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5c324294ce8488537c68085b187c9fe2a51664c4
commit 5c324294ce8488537c68085b187c9fe2a51664c4
Author: Brad King <brad.king at kitware.com>
AuthorDate: Tue Mar 29 10:31:21 2016 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Tue Mar 29 10:32:28 2016 -0400
cmConditionEvaluator: Pre-allocate keyword strings
Calls to `IsKeyword("...")` cause runtime construction of std::string.
Avoid possible repeated allocation by pre-allocating keyword strings
during initialization.
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx
index 6a0ebec..305ebe3 100644
--- a/Source/cmConditionEvaluator.cxx
+++ b/Source/cmConditionEvaluator.cxx
@@ -14,6 +14,33 @@
#include "cmOutputConverter.h"
#include "cmAlgorithms.h"
+static std::string const keyAND = "AND";
+static std::string const keyCOMMAND = "COMMAND";
+static std::string const keyDEFINED = "DEFINED";
+static std::string const keyEQUAL = "EQUAL";
+static std::string const keyEXISTS = "EXISTS";
+static std::string const keyGREATER = "GREATER";
+static std::string const keyIN_LIST = "IN_LIST";
+static std::string const keyIS_ABSOLUTE = "IS_ABSOLUTE";
+static std::string const keyIS_DIRECTORY = "IS_DIRECTORY";
+static std::string const keyIS_NEWER_THAN = "IS_NEWER_THAN";
+static std::string const keyIS_SYMLINK = "IS_SYMLINK";
+static std::string const keyLESS = "LESS";
+static std::string const keyMATCHES = "MATCHES";
+static std::string const keyNOT = "NOT";
+static std::string const keyOR = "OR";
+static std::string const keyParenL = "(";
+static std::string const keyParenR = ")";
+static std::string const keyPOLICY = "POLICY";
+static std::string const keySTREQUAL = "STREQUAL";
+static std::string const keySTRGREATER = "STRGREATER";
+static std::string const keySTRLESS = "STRLESS";
+static std::string const keyTARGET = "TARGET";
+static std::string const keyTEST = "TEST";
+static std::string const keyVERSION_EQUAL = "VERSION_EQUAL";
+static std::string const keyVERSION_GREATER = "VERSION_GREATER";
+static std::string const keyVERSION_LESS = "VERSION_LESS";
+
cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile,
const cmListFileContext &context,
const cmListFileBacktrace& bt):
@@ -400,7 +427,7 @@ bool cmConditionEvaluator::HandleLevel0(cmArgumentList &newArgs,
cmArgumentList::iterator arg = newArgs.begin();
while (arg != newArgs.end())
{
- if (IsKeyword("(", *arg))
+ if (IsKeyword(keyParenL, *arg))
{
// search for the closing paren for this opening one
cmArgumentList::iterator argClose;
@@ -409,11 +436,11 @@ bool cmConditionEvaluator::HandleLevel0(cmArgumentList &newArgs,
unsigned int depth = 1;
while (argClose != newArgs.end() && depth)
{
- if (this->IsKeyword("(", *argClose))
+ if (this->IsKeyword(keyParenL, *argClose))
{
depth++;
}
- if (this->IsKeyword(")", *argClose))
+ if (this->IsKeyword(keyParenR, *argClose))
{
depth--;
}
@@ -474,35 +501,35 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList &newArgs,
argP1 = arg;
this->IncrementArguments(newArgs,argP1,argP2);
// does a file exist
- if (this->IsKeyword("EXISTS", *arg) && argP1 != newArgs.end())
+ if (this->IsKeyword(keyEXISTS, *arg) && argP1 != newArgs.end())
{
this->HandlePredicate(
cmSystemTools::FileExists(argP1->c_str()),
reducible, arg, newArgs, argP1, argP2);
}
// does a directory with this name exist
- if (this->IsKeyword("IS_DIRECTORY", *arg) && argP1 != newArgs.end())
+ if (this->IsKeyword(keyIS_DIRECTORY, *arg) && argP1 != newArgs.end())
{
this->HandlePredicate(
cmSystemTools::FileIsDirectory(argP1->c_str()),
reducible, arg, newArgs, argP1, argP2);
}
// does a symlink with this name exist
- if (this->IsKeyword("IS_SYMLINK", *arg) && argP1 != newArgs.end())
+ if (this->IsKeyword(keyIS_SYMLINK, *arg) && argP1 != newArgs.end())
{
this->HandlePredicate(
cmSystemTools::FileIsSymlink(argP1->c_str()),
reducible, arg, newArgs, argP1, argP2);
}
// is the given path an absolute path ?
- if (this->IsKeyword("IS_ABSOLUTE", *arg) && argP1 != newArgs.end())
+ if (this->IsKeyword(keyIS_ABSOLUTE, *arg) && argP1 != newArgs.end())
{
this->HandlePredicate(
cmSystemTools::FileIsFullPath(argP1->c_str()),
reducible, arg, newArgs, argP1, argP2);
}
// does a command exist
- if (this->IsKeyword("COMMAND", *arg) && argP1 != newArgs.end())
+ if (this->IsKeyword(keyCOMMAND, *arg) && argP1 != newArgs.end())
{
cmCommand* command =
this->Makefile.GetState()->GetCommand(argP1->c_str());
@@ -511,7 +538,7 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList &newArgs,
reducible, arg, newArgs, argP1, argP2);
}
// does a policy exist
- if (this->IsKeyword("POLICY", *arg) && argP1 != newArgs.end())
+ if (this->IsKeyword(keyPOLICY, *arg) && argP1 != newArgs.end())
{
cmPolicies::PolicyID pid;
this->HandlePredicate(
@@ -519,7 +546,7 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList &newArgs,
reducible, arg, newArgs, argP1, argP2);
}
// does a target exist
- if (this->IsKeyword("TARGET", *arg) && argP1 != newArgs.end())
+ if (this->IsKeyword(keyTARGET, *arg) && argP1 != newArgs.end())
{
this->HandlePredicate(
this->Makefile.FindTargetToUse(argP1->GetValue())?true:false,
@@ -529,7 +556,7 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList &newArgs,
if(this->Policy64Status != cmPolicies::OLD &&
this->Policy64Status != cmPolicies::WARN)
{
- if (this->IsKeyword("TEST", *arg) && argP1 != newArgs.end())
+ if (this->IsKeyword(keyTEST, *arg) && argP1 != newArgs.end())
{
const cmTest* haveTest = this->Makefile.GetTest(argP1->c_str());
this->HandlePredicate(
@@ -538,7 +565,7 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList &newArgs,
}
}
else if(this->Policy64Status == cmPolicies::WARN &&
- this->IsKeyword("TEST", *arg))
+ this->IsKeyword(keyTEST, *arg))
{
std::ostringstream e;
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0064) << "\n";
@@ -549,7 +576,7 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList &newArgs,
this->Makefile.IssueMessage(cmake::AUTHOR_WARNING, e.str());
}
// is a variable defined
- if (this->IsKeyword("DEFINED", *arg) && argP1 != newArgs.end())
+ if (this->IsKeyword(keyDEFINED, *arg) && argP1 != newArgs.end())
{
size_t argP1len = argP1->GetValue().size();
bool bdef = false;
@@ -593,7 +620,7 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList &newArgs,
argP1 = arg;
this->IncrementArguments(newArgs,argP1,argP2);
if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
- IsKeyword("MATCHES", *argP1))
+ IsKeyword(keyMATCHES, *argP1))
{
def = this->GetVariableOrString(*arg);
if (def != arg->c_str() // yes, we compare the pointer value
@@ -631,7 +658,7 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList &newArgs,
reducible = 1;
}
- if (argP1 != newArgs.end() && this->IsKeyword("MATCHES", *arg))
+ if (argP1 != newArgs.end() && this->IsKeyword(keyMATCHES, *arg))
{
*arg = cmExpandedCommandArgument("0", true);
newArgs.erase(argP1);
@@ -641,9 +668,9 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList &newArgs,
}
if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
- (this->IsKeyword("LESS", *argP1) ||
- this->IsKeyword("GREATER", *argP1) ||
- this->IsKeyword("EQUAL", *argP1)))
+ (this->IsKeyword(keyLESS, *argP1) ||
+ this->IsKeyword(keyGREATER, *argP1) ||
+ this->IsKeyword(keyEQUAL, *argP1)))
{
def = this->GetVariableOrString(*arg);
def2 = this->GetVariableOrString(*argP2);
@@ -672,9 +699,9 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList &newArgs,
}
if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
- (this->IsKeyword("STRLESS", *argP1) ||
- this->IsKeyword("STREQUAL", *argP1) ||
- this->IsKeyword("STRGREATER", *argP1)))
+ (this->IsKeyword(keySTRLESS, *argP1) ||
+ this->IsKeyword(keySTREQUAL, *argP1) ||
+ this->IsKeyword(keySTRGREATER, *argP1)))
{
def = this->GetVariableOrString(*arg);
def2 = this->GetVariableOrString(*argP2);
@@ -697,18 +724,18 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList &newArgs,
}
if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
- (this->IsKeyword("VERSION_LESS", *argP1) ||
- this->IsKeyword("VERSION_GREATER", *argP1) ||
- this->IsKeyword("VERSION_EQUAL", *argP1)))
+ (this->IsKeyword(keyVERSION_LESS, *argP1) ||
+ this->IsKeyword(keyVERSION_GREATER, *argP1) ||
+ this->IsKeyword(keyVERSION_EQUAL, *argP1)))
{
def = this->GetVariableOrString(*arg);
def2 = this->GetVariableOrString(*argP2);
cmSystemTools::CompareOp op = cmSystemTools::OP_EQUAL;
- if(*argP1 == "VERSION_LESS")
+ if(*argP1 == keyVERSION_LESS)
{
op = cmSystemTools::OP_LESS;
}
- else if(*argP1 == "VERSION_GREATER")
+ else if(*argP1 == keyVERSION_GREATER)
{
op = cmSystemTools::OP_GREATER;
}
@@ -719,7 +746,7 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList &newArgs,
// is file A newer than file B
if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
- this->IsKeyword("IS_NEWER_THAN", *argP1))
+ this->IsKeyword(keyIS_NEWER_THAN, *argP1))
{
int fileIsNewer=0;
bool success=cmSystemTools::FileTimeCompare(arg->GetValue(),
@@ -731,7 +758,7 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList &newArgs,
}
if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
- this->IsKeyword("IN_LIST", *argP1))
+ this->IsKeyword(keyIN_LIST, *argP1))
{
if(this->Policy57Status != cmPolicies::OLD &&
this->Policy57Status != cmPolicies::WARN)
@@ -788,7 +815,7 @@ bool cmConditionEvaluator::HandleLevel3(cmArgumentList &newArgs,
{
argP1 = arg;
IncrementArguments(newArgs,argP1,argP2);
- if (argP1 != newArgs.end() && IsKeyword("NOT", *arg))
+ if (argP1 != newArgs.end() && IsKeyword(keyNOT, *arg))
{
bool rhs = this->GetBooleanValueWithAutoDereference(*argP1,
errorString,
@@ -821,7 +848,7 @@ bool cmConditionEvaluator::HandleLevel4(cmArgumentList &newArgs,
{
argP1 = arg;
IncrementArguments(newArgs,argP1,argP2);
- if (argP1 != newArgs.end() && IsKeyword("AND", *argP1) &&
+ if (argP1 != newArgs.end() && IsKeyword(keyAND, *argP1) &&
argP2 != newArgs.end())
{
lhs = this->GetBooleanValueWithAutoDereference(*arg,
@@ -834,7 +861,7 @@ bool cmConditionEvaluator::HandleLevel4(cmArgumentList &newArgs,
reducible, arg, newArgs, argP1, argP2);
}
- if (argP1 != newArgs.end() && this->IsKeyword("OR", *argP1) &&
+ if (argP1 != newArgs.end() && this->IsKeyword(keyOR, *argP1) &&
argP2 != newArgs.end())
{
lhs = this->GetBooleanValueWithAutoDereference(*arg,
-----------------------------------------------------------------------
Summary of changes:
Source/cmConditionEvaluator.cxx | 89 +++++++++++++++++++++++++--------------
1 file changed, 58 insertions(+), 31 deletions(-)
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list