autoconf-patches
[Top][All Lists]
Advanced

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

Re: another m4sugar speedup


From: Eric Blake
Subject: Re: another m4sugar speedup
Date: Tue, 02 Oct 2007 20:24:59 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070728 Thunderbird/2.0.0.6 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Eric Blake on 10/2/2007 3:47 PM:
> 2007-10-02  Eric Blake  <address@hidden>
> 
>       Optimize recursion.
>       * lib/m4sugar/m4sugar.m4 (m4_shiftn): This macro is called in a
>       lot of hot spots; optimize it for 2 and 3 shifts.

And another one.  It's rather wasteful to use one regex to escape the
target string, just so the target string can be used as another regex,
when a straight index does the same thing faster.  This speeds up
_AC_PRECIOUS_VARS, _AC_SUBST_VARS, and others.

2007-10-02  Eric Blake  <address@hidden>

        Optimize appending text.
        * lib/m4sugar/m4sugar.m4 (m4_append_uniq): Use index, not regular
        expressions.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHAv1684KuGfSFAYARApUNAKC1SaYG0hdW4kySQzFKX9BlROnzKQCgtsw3
YvMUMermeXs6WwAUQHi/zto=
=8ATj
-----END PGP SIGNATURE-----
>From 53b2e90b426a4b7da56629feefbc065574d447c0 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Tue, 2 Oct 2007 20:23:03 -0600
Subject: [PATCH] Optimize appending text.

* lib/m4sugar/m4sugar.m4 (m4_append_uniq): Use index, not regular
expressions.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog              |    4 ++++
 lib/m4sugar/m4sugar.m4 |    6 +++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 13aa85a..26833bc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2007-10-02  Eric Blake  <address@hidden>
 
+       Optimize appending text.
+       * lib/m4sugar/m4sugar.m4 (m4_append_uniq): Use index, not regular
+       expressions.
+
        Optimize recursion.
        * lib/m4sugar/m4sugar.m4 (m4_shiftn): This macro is called in a
        lot of hot spots; optimize it for 2 and 3 shifts.
diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4
index 7b20095..f180e87 100644
--- a/lib/m4sugar/m4sugar.m4
+++ b/lib/m4sugar/m4sugar.m4
@@ -1553,11 +1553,11 @@ m4_define([m4_append],
 
 # m4_append_uniq(MACRO-NAME, STRING, [SEPARATOR])
 # -----------------------------------------------
-# As `m4_append', but append only if not yet present.
+# Like `m4_append', but append only if not yet present.
 m4_define([m4_append_uniq],
 [m4_ifdef([$1],
-         [m4_bmatch([$3]m4_defn([$1])[$3], m4_re_escape([$3$2$3]), [],
-                    [m4_append($@)])],
+         [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
+                [m4_append($@)])],
          [m4_append($@)])])
 
 
-- 
1.5.3.2


reply via email to

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