]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Speed up m4_qlen with caching.
authorEric Blake <ebb9@byu.net>
Thu, 16 Oct 2008 16:14:09 +0000 (10:14 -0600)
committerEric Blake <ebb9@byu.net>
Thu, 16 Oct 2008 16:50:25 +0000 (10:50 -0600)
* lib/m4sugar/m4sugar.m4 (_m4_qlen): Renamed from old m4_qlen.
(m4_qlen): Cache results for speed.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
lib/m4sugar/m4sugar.m4

index 8eef61de75d1fb3cff0b9b258c9e1cae5b3fa710..dfbbdfd05020c448ced831dfbee7dde52cc87a63 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-10-16  Eric Blake  <ebb9@byu.net>
+
+       Speed up m4_qlen with caching.
+       * lib/m4sugar/m4sugar.m4 (_m4_qlen): Renamed from old m4_qlen.
+       (m4_qlen): Cache results for speed.
+
 2008-10-16  Paolo Bonzini  <bonzini@gnu.org>
 
        Add a testcase using more then one language.
index 2e02a773eb1d383dd5c18d9686a955d3c4322739..681f4b0df1d8b922a42d80583410e96f1ffb024c 100644 (file)
@@ -2221,7 +2221,7 @@ dnl either way, insert the word
                      m4_eval(m4_Indent + m4_qlen(_m4_defn([m4_Word])) + 1))
 [$2]],
       [m4_Separator[]])_m4_defn([m4_Word])])]],
-dnl finally, clean up the local variabls
+dnl finally, clean up the local variables
 [[_m4_popdef([m4_Separator], [m4_Cursor], [m4_Indent])]]))
 
 
@@ -2246,12 +2246,19 @@ m4_define([m4_text_box],
 # ---------------
 # Expands to the length of STRING after autom4te converts all quadrigraphs.
 #
-# Avoid bpatsubsts for the common case of no quadrigraphs.
+# Avoid bpatsubsts for the common case of no quadrigraphs.  Cache
+# results, as configure scripts tend to ask about lengths of common
+# strings like `/*' and `*/' rather frequently.  Minimize the number
+# of times that $1 occurs in m4_qlen, so there is less text to parse
+# on a cache hit.
 m4_define([m4_qlen],
-[m4_if(m4_index([$1], [@]), [-1], [m4_len([$1])],
-       [m4_len(m4_bpatsubst([[$1]],
-                           [@\(\(<:\|:>\|S|\|%:\|\{:\|:\}\)\(@\)\|&t@\)],
-                           [\3]))])])
+[m4_ifdef([$0-$1], [_m4_defn([$0-]], [_$0(])[$1])])
+m4_define([_m4_qlen],
+[m4_define([m4_qlen-$1],
+m4_if(m4_index([$1], [@]), [-1], [m4_len([$1])],
+      [m4_len(m4_bpatsubst([[$1]],
+                          [@\(\(<:\|:>\|S|\|%:\|\{:\|:\}\)\(@\)\|&t@\)],
+                          [\3]))]))_m4_defn([m4_qlen-$1])])
 
 
 # m4_qdelta(STRING)