summaryrefslogtreecommitdiff
path: root/Source/cmGeneratorExpressionEvaluator.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2014-04-30 13:12:29 -0400
committerBen Boeckel <ben.boeckel@kitware.com>2014-06-09 14:45:35 -0400
commit3e7194a215aed5e34acf32ad4b8c6bd948beb15e (patch)
treed64f0613579fdf8fda51ce8fd05f6045a3a2142e /Source/cmGeneratorExpressionEvaluator.cxx
parent9e8fa1043ce9bfcffdcfa395f618dd7958ef4251 (diff)
downloadcmake-3e7194a215aed5e34acf32ad4b8c6bd948beb15e.tar.gz
regex: Use static regexs where possible
Rather than declaring and compiling a constant regex every time a chunk of code is executed, build the regex once.
Diffstat (limited to 'Source/cmGeneratorExpressionEvaluator.cxx')
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx12
1 files changed, 4 insertions, 8 deletions
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index c54922d72a..07362c3f5f 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -401,8 +401,7 @@ struct CompilerIdNode : public cmGeneratorExpressionNode
{
return compilerId ? compilerId : "";
}
- cmsys::RegularExpression compilerIdValidator;
- compilerIdValidator.compile("^[A-Za-z0-9_]*$");
+ static cmsys::RegularExpression compilerIdValidator("^[A-Za-z0-9_]*$");
if (!compilerIdValidator.find(parameters.begin()->c_str()))
{
reportError(context, content->GetOriginalExpression(),
@@ -509,8 +508,7 @@ struct CompilerVersionNode : public cmGeneratorExpressionNode
return compilerVersion ? compilerVersion : "";
}
- cmsys::RegularExpression compilerIdValidator;
- compilerIdValidator.compile("^[0-9\\.]*$");
+ static cmsys::RegularExpression compilerIdValidator("^[0-9\\.]*$");
if (!compilerIdValidator.find(parameters.begin()->c_str()))
{
reportError(context, content->GetOriginalExpression(),
@@ -711,8 +709,7 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
{
return configurationNode.Evaluate(parameters, context, content, 0);
}
- cmsys::RegularExpression configValidator;
- configValidator.compile("^[A-Za-z0-9_]*$");
+ static cmsys::RegularExpression configValidator("^[A-Za-z0-9_]*$");
if (!configValidator.find(parameters.begin()->c_str()))
{
reportError(context, content->GetOriginalExpression(),
@@ -884,8 +881,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
"$<TARGET_PROPERTY:...> expression requires one or two parameters");
return std::string();
}
- cmsys::RegularExpression propertyNameValidator;
- propertyNameValidator.compile("^[A-Za-z0-9_]+$");
+ static cmsys::RegularExpression propertyNameValidator("^[A-Za-z0-9_]+$");
cmTarget const* target = context->HeadTarget;
std::string propertyName = *parameters.begin();