genex: Store predicates as a map for faster searching

May warrant a fast path for predicates which more frequently.
This commit is contained in:
Ben Boeckel 2014-02-06 13:59:50 -05:00 committed by Brad King
parent 22c54a1090
commit 24e8b929ee
1 changed files with 52 additions and 83 deletions

View File

@ -1555,89 +1555,58 @@ TargetFilesystemArtifact<false, true, true, false> targetSoNameFileDirNode;
static const static const
cmGeneratorExpressionNode* GetNode(const std::string &identifier) cmGeneratorExpressionNode* GetNode(const std::string &identifier)
{ {
if (identifier == "0") typedef std::map<std::string, const cmGeneratorExpressionNode*> NodeMap;
return &zeroNode; static NodeMap nodeMap;
else if (identifier == "1") if (nodeMap.empty())
return &oneNode; {
else if (identifier == "AND") nodeMap["0"] = &zeroNode;
return &andNode; nodeMap["1"] = &oneNode;
else if (identifier == "OR") nodeMap["AND"] = &andNode;
return &orNode; nodeMap["OR"] = &orNode;
else if (identifier == "NOT") nodeMap["NOT"] = &notNode;
return &notNode; nodeMap["C_COMPILER_ID"] = &cCompilerIdNode;
else if (identifier == "C_COMPILER_ID") nodeMap["CXX_COMPILER_ID"] = &cxxCompilerIdNode;
return &cCompilerIdNode; nodeMap["VERSION_GREATER"] = &versionGreaterNode;
else if (identifier == "CXX_COMPILER_ID") nodeMap["VERSION_LESS"] = &versionLessNode;
return &cxxCompilerIdNode; nodeMap["VERSION_EQUAL"] = &versionEqualNode;
else if (identifier == "VERSION_GREATER") nodeMap["C_COMPILER_VERSION"] = &cCompilerVersionNode;
return &versionGreaterNode; nodeMap["CXX_COMPILER_VERSION"] = &cxxCompilerVersionNode;
else if (identifier == "VERSION_LESS") nodeMap["PLATFORM_ID"] = &platformIdNode;
return &versionLessNode; nodeMap["CONFIGURATION"] = &configurationNode;
else if (identifier == "VERSION_EQUAL") nodeMap["CONFIG"] = &configurationTestNode;
return &versionEqualNode; nodeMap["TARGET_FILE"] = &targetFileNode;
else if (identifier == "C_COMPILER_VERSION") nodeMap["TARGET_LINKER_FILE"] = &targetLinkerFileNode;
return &cCompilerVersionNode; nodeMap["TARGET_SONAME_FILE"] = &targetSoNameFileNode;
else if (identifier == "CXX_COMPILER_VERSION") nodeMap["TARGET_FILE_NAME"] = &targetFileNameNode;
return &cxxCompilerVersionNode; nodeMap["TARGET_LINKER_FILE_NAME"] = &targetLinkerFileNameNode;
else if (identifier == "PLATFORM_ID") nodeMap["TARGET_SONAME_FILE_NAME"] = &targetSoNameFileNameNode;
return &platformIdNode; nodeMap["TARGET_FILE_DIR"] = &targetFileDirNode;
else if (identifier == "CONFIGURATION") nodeMap["TARGET_LINKER_FILE_DIR"] = &targetLinkerFileDirNode;
return &configurationNode; nodeMap["TARGET_SONAME_FILE_DIR"] = &targetSoNameFileDirNode;
else if (identifier == "CONFIG") nodeMap["STREQUAL"] = &strEqualNode;
return &configurationTestNode; nodeMap["EQUAL"] = &equalNode;
else if (identifier == "TARGET_FILE") nodeMap["LOWER_CASE"] = &lowerCaseNode;
return &targetFileNode; nodeMap["UPPER_CASE"] = &upperCaseNode;
else if (identifier == "TARGET_LINKER_FILE") nodeMap["MAKE_C_IDENTIFIER"] = &makeCIdentifierNode;
return &targetLinkerFileNode; nodeMap["BOOL"] = &boolNode;
else if (identifier == "TARGET_SONAME_FILE") nodeMap["ANGLE-R"] = &angle_rNode;
return &targetSoNameFileNode; nodeMap["COMMA"] = &commaNode;
else if (identifier == "TARGET_FILE_NAME") nodeMap["SEMICOLON"] = &semicolonNode;
return &targetFileNameNode; nodeMap["TARGET_PROPERTY"] = &targetPropertyNode;
else if (identifier == "TARGET_LINKER_FILE_NAME") nodeMap["TARGET_NAME"] = &targetNameNode;
return &targetLinkerFileNameNode; nodeMap["TARGET_POLICY"] = &targetPolicyNode;
else if (identifier == "TARGET_SONAME_FILE_NAME") nodeMap["BUILD_INTERFACE"] = &buildInterfaceNode;
return &targetSoNameFileNameNode; nodeMap["INSTALL_INTERFACE"] = &installInterfaceNode;
else if (identifier == "TARGET_FILE_DIR") nodeMap["INSTALL_PREFIX"] = &installPrefixNode;
return &targetFileDirNode; nodeMap["JOIN"] = &joinNode;
else if (identifier == "TARGET_LINKER_FILE_DIR") nodeMap["LINK_ONLY"] = &linkOnlyNode;
return &targetLinkerFileDirNode; }
else if (identifier == "TARGET_SONAME_FILE_DIR") NodeMap::const_iterator i = nodeMap.find(identifier);
return &targetSoNameFileDirNode; if (i == nodeMap.end())
else if (identifier == "STREQUAL") {
return &strEqualNode; return 0;
else if (identifier == "EQUAL") }
return &equalNode; return i->second;
else if (identifier == "LOWER_CASE")
return &lowerCaseNode;
else if (identifier == "UPPER_CASE")
return &upperCaseNode;
else if (identifier == "MAKE_C_IDENTIFIER")
return &makeCIdentifierNode;
else if (identifier == "BOOL")
return &boolNode;
else if (identifier == "ANGLE-R")
return &angle_rNode;
else if (identifier == "COMMA")
return &commaNode;
else if (identifier == "SEMICOLON")
return &semicolonNode;
else if (identifier == "TARGET_PROPERTY")
return &targetPropertyNode;
else if (identifier == "TARGET_NAME")
return &targetNameNode;
else if (identifier == "TARGET_POLICY")
return &targetPolicyNode;
else if (identifier == "BUILD_INTERFACE")
return &buildInterfaceNode;
else if (identifier == "INSTALL_INTERFACE")
return &installInterfaceNode;
else if (identifier == "INSTALL_PREFIX")
return &installPrefixNode;
else if (identifier == "JOIN")
return &joinNode;
else if (identifier == "LINK_ONLY")
return &linkOnlyNode;
return 0;
} }