autoconf-patches
[Top][All Lists]
Advanced

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

Re: [PATCH] Speedup creation of configure.lineno


From: Paul Eggert
Subject: Re: [PATCH] Speedup creation of configure.lineno
Date: 04 Jan 2004 23:51:13 -0800
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

"Paolo Bonzini" <address@hidden> writes:

> The attached patch modifies the sed scripts to be 4 times faster
> than those in the current autoconf.

Thanks for the suggestion, it does look like a performance win on
older hosts.  But out of curiosity, why was this worth your time?  Are
you running 'configure' scripts on machines that lack modern shells,
and where 'sed' is slow?

> +       /$LINENO/=' <$as_myself |

For portability the $ needs to be escaped from 'sed' by surrounding it
with square brackets, which in turn need to be doubled, thus: [[$]]LINENO.

> +      tok

POSIX says that a space must separate the 't' command from the label.

> +      s,$LINENO\([[^'$as_cr_alnum'_]]\)\([[^\n]]*\n\)\(.*\),\3\1\2\3,

Hmm, "[^\n]" doesn't have the seemingly-expected meaning here, as
backslash loses its special meaning within a bracket expression.  See
<http://www.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap09.html>.

(Isn't 'sed' fun?  :-)

I installed the following patch instead: I hope it works for you.
I can't easily test it, as I lack access to ancient hosts these days.

2004-01-04  Paul Eggert  <address@hidden>
            Paolo Bonzini  <address@hidden>

        * libc/m4sugar/m4sh.m4 (_AS_LINENO_PREPARE): Speed up sed scripts
        by doing lineno substitution only on lines containing "$LINENO".

Index: m4sh.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sh.m4,v
retrieving revision 1.110
retrieving revision 1.111
diff -p -u -r1.110 -r1.111
--- m4sh.m4     5 Jan 2004 07:05:22 -0000       1.110
+++ m4sh.m4     5 Jan 2004 07:43:48 -0000       1.111
@@ -653,21 +653,28 @@ _AS_LINENO_WORKS || {
 
   # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
   # uniformly replaced by the line number.  The first 'sed' inserts a
-  # line-number line before each line; the second 'sed' does the real
-  # work.  The second script uses 'N' to pair each line-number line
-  # with the numbered line, and appends trailing '-' during
-  # substitution so that $LINENO is not a special case at line end.
+  # line-number line after each line using $LINENO; the second 'sed'
+  # does the real work.  The second script uses 'N' to pair each
+  # line-number line with the line containing $LINENO, and appends
+  # trailing '-' during substitution so that $LINENO is not a special
+  # case at line end.
   # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
-  # second 'sed' script.  Blame Lee E. McMahon for sed's syntax.  :-)
-  sed '=' <$as_myself |
+  # scripts with optimization help from Paolo Bonzini.  Blame Lee
+  # E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[[$]]LINENO/=
+  ' <$as_myself |
     sed '
+      s,[[$]]LINENO.*,&-,
+      t lineno
+      b
+      : lineno
       N
-      s,$,-,
       : loop
-      
s,^\([['$as_cr_digits']]*\)\(.*\)[[$]]LINENO\([[^'$as_cr_alnum'_]]\),\1\2\1\3,
+      s,[[$]]LINENO\([[^'$as_cr_alnum'_]].*\n\)\(.*\),\2\1\2,
       t loop
-      s,-$,,
-      s,^[['$as_cr_digits']]*\n,,
+      s,-\n.*,,
     ' >$as_me.lineno &&
   chmod +x $as_me.lineno ||
     AS_ERROR([cannot create $as_me.lineno; rerun with a POSIX shell])




reply via email to

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