diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2014-04-30 17:12:29 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2014-06-09 18:45:35 (GMT) |
commit | 3e7194a215aed5e34acf32ad4b8c6bd948beb15e (patch) | |
tree | d64f0613579fdf8fda51ce8fd05f6045a3a2142e /Source | |
parent | 9e8fa1043ce9bfcffdcfa395f618dd7958ef4251 (diff) | |
download | CMake-3e7194a215aed5e34acf32ad4b8c6bd948beb15e.zip CMake-3e7194a215aed5e34acf32ad4b8c6bd948beb15e.tar.gz CMake-3e7194a215aed5e34acf32ad4b8c6bd948beb15e.tar.bz2 |
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')
-rw-r--r-- | Source/CPack/cmCPackNSISGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmComputeLinkInformation.cxx | 4 | ||||
-rw-r--r-- | Source/cmGeneratorExpression.cxx | 5 | ||||
-rw-r--r-- | Source/cmGeneratorExpressionEvaluator.cxx | 12 | ||||
-rw-r--r-- | Source/cmOrderDirectories.cxx | 8 |
5 files changed, 14 insertions, 19 deletions
diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 0113698..a5eee6b 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -588,8 +588,8 @@ void cmCPackNSISGenerator::CreateMenuLinks( cmOStringStream& str, return; } - cmsys::RegularExpression urlRegex; - urlRegex.compile("^(mailto:|(ftps?|https?|news)://).*$"); + static cmsys::RegularExpression + urlRegex("^(mailto:|(ftps?|https?|news)://).*$"); std::vector<std::string>::iterator it; for ( it = cpackMenuLinksVector.begin(); diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index ea8536f..70f02d6 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1831,8 +1831,8 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath) { if(fullPath.find(".framework") != std::string::npos) { - cmsys::RegularExpression splitFramework; - splitFramework.compile("^(.*)/(.*).framework/(.*)$"); + static cmsys::RegularExpression + splitFramework("^(.*)/(.*).framework/(.*)$"); if(splitFramework.find(fullPath) && (std::string::npos != splitFramework.match(3).find(splitFramework.match(2)))) diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 028d229..2b4d955 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -469,12 +469,11 @@ std::string::size_type cmGeneratorExpression::Find(const std::string &input) //---------------------------------------------------------------------------- bool cmGeneratorExpression::IsValidTargetName(const std::string &input) { - cmsys::RegularExpression targetNameValidator; // The ':' is supported to allow use with IMPORTED targets. At least // Qt 4 and 5 IMPORTED targets use ':' as the namespace delimiter. - targetNameValidator.compile("^[A-Za-z0-9_.:+-]+$"); + static cmsys::RegularExpression targetNameValidator("^[A-Za-z0-9_.:+-]+$"); - return targetNameValidator.find(input.c_str()); + return targetNameValidator.find(input); } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index c54922d..07362c3 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(); diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index ec671fc..71a3497 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -39,8 +39,8 @@ public: if(file.rfind(".framework") != std::string::npos) { - cmsys::RegularExpression splitFramework; - splitFramework.compile("^(.*)/(.*).framework/(.*)$"); + static cmsys::RegularExpression + splitFramework("^(.*)/(.*).framework/(.*)$"); if(splitFramework.find(file) && (std::string::npos != splitFramework.match(3).find(splitFramework.match(2)))) @@ -326,8 +326,8 @@ void cmOrderDirectories::AddRuntimeLibrary(std::string const& fullPath, if(fullPath.rfind(".framework") != std::string::npos) { - cmsys::RegularExpression splitFramework; - splitFramework.compile("^(.*)/(.*).framework/(.*)$"); + static cmsys::RegularExpression + splitFramework("^(.*)/(.*).framework/(.*)$"); if(splitFramework.find(fullPath) && (std::string::npos != splitFramework.match(3).find(splitFramework.match(2)))) |