ソースを参照

Genex: Avoid repeated search of transitive property whitelist

In cmGeneratorExpressionEvaluator, avoid searching through the list of
transitive interface property names repeatedly during evaluation of
TargetPropertyNode.  Simply record the results of the first search for
later re-use.
Brad King 11 年 前
コミット
60bafeb684
1 ファイル変更26 行追加33 行削除
  1. 26 33
      Source/cmGeneratorExpressionEvaluator.cxx

+ 26 - 33
Source/cmGeneratorExpressionEvaluator.cxx

@@ -1044,12 +1044,18 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
     std::string linkedTargetsContent;
     std::string linkedTargetsContent;
 
 
     std::string interfacePropertyName;
     std::string interfacePropertyName;
+    bool isInterfaceProperty = false;
 
 
 #define POPULATE_INTERFACE_PROPERTY_NAME(prop) \
 #define POPULATE_INTERFACE_PROPERTY_NAME(prop) \
-    if (propertyName == #prop || propertyName == "INTERFACE_" #prop) \
+    if (propertyName == #prop) \
       { \
       { \
       interfacePropertyName = "INTERFACE_" #prop; \
       interfacePropertyName = "INTERFACE_" #prop; \
       } \
       } \
+    else if (propertyName == "INTERFACE_" #prop) \
+      { \
+      interfacePropertyName = "INTERFACE_" #prop; \
+      isInterfaceProperty = true; \
+      } \
     else
     else
 
 
     CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(POPULATE_INTERFACE_PROPERTY_NAME)
     CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(POPULATE_INTERFACE_PROPERTY_NAME)
@@ -1065,17 +1071,10 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
         }
         }
       }
       }
 #undef POPULATE_INTERFACE_PROPERTY_NAME
 #undef POPULATE_INTERFACE_PROPERTY_NAME
-
     cmTarget const* headTarget = context->HeadTarget
     cmTarget const* headTarget = context->HeadTarget
                                ? context->HeadTarget : target;
                                ? context->HeadTarget : target;
 
 
-    const char * const *transBegin =
-                        cmArrayBegin(targetPropertyTransitiveWhitelist) + 1;
-    const char * const *transEnd =
-                        cmArrayEnd(targetPropertyTransitiveWhitelist);
-
-    if (std::find_if(transBegin, transEnd,
-                     cmStrCmp(propertyName)) != transEnd)
+    if(isInterfaceProperty)
       {
       {
       if(cmTarget::LinkInterfaceLibraries const* iface =
       if(cmTarget::LinkInterfaceLibraries const* iface =
          target->GetLinkInterfaceLibraries(context->Config, headTarget, true))
          target->GetLinkInterfaceLibraries(context->Config, headTarget, true))
@@ -1087,18 +1086,17 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
                                   interfacePropertyName);
                                   interfacePropertyName);
         }
         }
       }
       }
-    else if (std::find_if(transBegin, transEnd,
-                          cmStrCmp(interfacePropertyName)) != transEnd)
+    else if(!interfacePropertyName.empty())
       {
       {
       const cmTarget::LinkImplementationLibraries *impl
       const cmTarget::LinkImplementationLibraries *impl
         = target->GetLinkImplementationLibraries(context->Config);
         = target->GetLinkImplementationLibraries(context->Config);
       if(impl)
       if(impl)
         {
         {
         linkedTargetsContent =
         linkedTargetsContent =
-                  getLinkedTargetsContent(impl->Libraries, target,
-                                          headTarget,
-                                          context, &dagChecker,
-                                          interfacePropertyName);
+          getLinkedTargetsContent(impl->Libraries, target,
+                                  headTarget,
+                                  context, &dagChecker,
+                                  interfacePropertyName);
         }
         }
       }
       }
 
 
@@ -1178,32 +1176,27 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
         return propContent ? propContent : "";
         return propContent ? propContent : "";
         }
         }
       }
       }
-    for (size_t i = 1;
-         i < cmArraySize(targetPropertyTransitiveWhitelist);
-         ++i)
+    if(!interfacePropertyName.empty())
       {
       {
-      if (targetPropertyTransitiveWhitelist[i] == interfacePropertyName)
-        {
-        cmGeneratorExpression ge(&context->Backtrace);
-        cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
-        cge->SetEvaluateForBuildsystem(context->EvaluateForBuildsystem);
-        std::string result = cge->Evaluate(context->Makefile,
+      cmGeneratorExpression ge(&context->Backtrace);
+      cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
+      cge->SetEvaluateForBuildsystem(context->EvaluateForBuildsystem);
+      std::string result = cge->Evaluate(context->Makefile,
                             context->Config,
                             context->Config,
                             context->Quiet,
                             context->Quiet,
                             headTarget,
                             headTarget,
                             target,
                             target,
                             &dagChecker);
                             &dagChecker);
 
 
-        if (cge->GetHadContextSensitiveCondition())
-          {
-          context->HadContextSensitiveCondition = true;
-          }
-        if (!linkedTargetsContent.empty())
-          {
-          result += (result.empty() ? "" : ";") + linkedTargetsContent;
-          }
-        return result;
+      if (cge->GetHadContextSensitiveCondition())
+        {
+        context->HadContextSensitiveCondition = true;
+        }
+      if (!linkedTargetsContent.empty())
+        {
+        result += (result.empty() ? "" : ";") + linkedTargetsContent;
         }
         }
+      return result;
       }
       }
     return prop;
     return prop;
   }
   }