automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FYI: speed up make_paragraph again


From: Alexandre Duret-Lutz
Subject: FYI: speed up make_paragraph again
Date: Sun, 08 Aug 2004 21:04:55 +0200
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)

I'm checking this in.

This caches some half-processed version of Automake's am files.
Some of them are read many times in a single run, or even during
the processing of the same Makefile.am (e.g., when outputting
non-generic rules -- this is probably even more obvious when
ansi2knr is used).

automaking Coreutils goes down from 6.38s to 5.94s; but that
does not appear to be a good example for this optimization.

2004-08-08  Alexandre Duret-Lutz  <address@hidden>

        * automake.in (%am_file_cache): New hash.
        (make_paragraphs): Cache .am files with comments stripped to save
        some useless input and substitutions.

Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1576
diff -u -r1.1576 automake.in
--- automake.in 8 Aug 2004 17:11:24 -0000       1.1576
+++ automake.in 8 Aug 2004 19:02:47 -0000
@@ -564,6 +564,12 @@
 # Record each file processed by make_paragraphs.
 my %transformed_files;
 
+# Cache each file processed by make_paragraphs.
+# (This is different from %transformed_files because
+# %transformed_files is reset for each file while %am_file_cache
+# it global to the run.)
+my %am_file_cache;
+
 ################################################################
 
 # var_SUFFIXES_trigger ($TYPE, $VALUE)
@@ -6171,20 +6177,26 @@
                %transform);
 
   $transformed_files{$file} = 1;
+  $_ = $am_file_cache{$file};
+
+  if (! defined $_)
+    {
+      verb "reading $file";
+      # Swallow the whole file.
+      my $fc_file = new Automake::XFile "< $file";
+      my $saved_dollar_slash = $/;
+      undef $/;
+      $_ = $fc_file->getline;
+      $/ = $saved_dollar_slash;
+      $fc_file->close;
+
+      # Remove ##-comments.
+      # Besides we don't need more than two consecutive new-lines.
+      s/(?:$IGNORE_PATTERN|(?<=\n\n)\n+)//gom;
+
+      $am_file_cache{$file} = $_;
+    }
 
-  # Swallow the file and apply the COMMAND.
-  my $fc_file = new Automake::XFile "< $file";
-  # Looks stupid?
-  verb "reading $file";
-  my $saved_dollar_slash = $/;
-  undef $/;
-  $_ = $fc_file->getline;
-  $/ = $saved_dollar_slash;
-  $fc_file->close;
-
-  # Remove ##-comments.
-  # Besides we don't need more than two consecutive new-lines.
-  s/(?:$IGNORE_PATTERN|(?<=\n\n)\n+)//gom;
   # Substitute Automake template tokens.
   s/(?:%\??[\w\-]+%|\?!?[\w\-]+\?)/transform($&, \%transform)/ge;
   # transform() may have added some ##%-comments to strip.
-- 
Alexandre Duret-Lutz





reply via email to

[Prev in Thread] Current Thread [Next in Thread]