Performance improvements
authorBoris Kolpackov <boris@kolpackov.net>
Mon, 5 Oct 2009 14:40:18 +0000 (14:40 +0000)
committerBoris Kolpackov <boris@kolpackov.net>
Mon, 5 Oct 2009 14:40:18 +0000 (14:40 +0000)
ChangeLog
implicit.c

index 860a1f4631a7167594dafff7135c8c8494c276d7..83e687feaccda57a4ef9f0dc29a54ac710add0fd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-10-05  Boris Kolpackov  <boris@codesynthesis.com>
+
+       * implicit.c (pattern_search): Initialize file variables only
+       if we need to parse a rule that requires the second expansion.
+
 2009-10-03  Paul Smith  <psmith@gnu.org>
 
        * make.h: Include <alloca.h> even on systems where __GNUC__ is
index 8ad63952be6ad1ede3abcfa5d9cd5c46c689989d..08e56bce40b57ff5479c78a386af88fbd33e1357 100644 (file)
@@ -247,6 +247,9 @@ pattern_search (struct file *file, int archive,
   /* Nonzero if should consider intermediate files as dependencies.  */
   int intermed_ok;
 
+  /* Nonzero if we have initialized file variables for this target.  */
+  int file_vars_initialized = 0;
+
   /* Nonzero if we have matched a pattern-rule target
      that is not just `%'.  */
   int specific_rule_matched = 0;
@@ -431,10 +434,6 @@ pattern_search (struct file *file, int archive,
               }
         }
 
-  /* We are going to do second expansion so initialize file variables
-     for the rule. */
-  initialize_file_variables (file, 0);
-
   /* Try each rule once without intermediate files, then once with them.  */
   for (intermed_ok = 0; intermed_ok < 2; ++intermed_ok)
     {
@@ -613,6 +612,14 @@ pattern_search (struct file *file, int archive,
                         add_dir = 1;
                     }
 
+                  /* Initialize file variables if we haven't already
+                     done so. */
+                  if (!file_vars_initialized)
+                    {
+                      initialize_file_variables (file, 0);
+                      file_vars_initialized = 1;
+                    }
+
                   /* Set file variables. Note that we cannot do it once at the
                      beginning of the function because the stem value changes
                      for each rule.  */