]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Minor optimizations to m4sh.
authorEric Blake <ebb9@byu.net>
Wed, 28 Oct 2009 18:21:36 +0000 (12:21 -0600)
committerEric Blake <ebb9@byu.net>
Thu, 29 Oct 2009 01:54:04 +0000 (19:54 -0600)
* lib/m4sugar/m4sh.m4 (AS_VAR_IF, AS_IDENTIFIER_IF)
(AS_LITERAL_IF): Parse fewer bytes during expansion, by visiting
if-true and if-false arguments only once.

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

index a9720393134177a2c0644d73ecfda3078bb43e1e..f28d97c3913d7aaa6cae403f202bedbff0b60169 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2009-10-28  Eric Blake  <ebb9@byu.net>
 
+       Minor optimizations to m4sh.
+       * lib/m4sugar/m4sh.m4 (AS_VAR_IF, AS_IDENTIFIER_IF)
+       (AS_LITERAL_IF): Parse fewer bytes during expansion, by visiting
+       if-true and if-false arguments only once.
+
        Optimize m4_escape for common case.
        * lib/m4sugar/m4sugar.m4 (m4_escape): Don't use regex if string is
        already sane, by copying from AS_LITERAL_IF.  Move guts...
index 48640882e3a164494b448cc297f83bcf30eb5abb..c1253091b40a99a1daf56e385a3ef76c00a4706a 100644 (file)
@@ -1507,15 +1507,15 @@ m4_define([AS_HELP_STRING],
 # we worry if the first character also matches m4_cr_symbol1 (ie. does not
 # match m4_cr_digit).
 m4_define([AS_IDENTIFIER_IF],
-[m4_if(m4_index([$1], [@]), [-1],
-       [_$0($@)],
-       [_$0(m4_bpatsubst([[$1]], [@&t@]), [$2], [$3])])])
+[m4_if(_$0(m4_if(m4_index([$1], [@]), [-1],
+  [[$1]], [m4_bpatsubst([[$1]], [@&t@])])), [-], [$2], [$3])])
+
 m4_define([_AS_IDENTIFIER_IF],
-[m4_cond([[$1]], [], [$3],
+[m4_cond([[$1]], [], [],
         [m4_eval(m4_len(m4_translit([[$1]], ]]dnl
-m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[)) > 0)], [1], [$3],
+m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[)) > 0)], [1], [],
         [m4_len(m4_translit(m4_format([[%.1s]], [$1]), ]]dnl
-m4_dquote(m4_dquote(m4_defn([m4_cr_symbols1])))[[))], [0], [$2], [$3])])
+m4_dquote(m4_dquote(m4_defn([m4_cr_symbols1])))[[))], [0], [-])])
 
 
 # AS_LITERAL_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL)
@@ -1544,13 +1544,10 @@ m4_dquote(m4_dquote(m4_defn([m4_cr_symbols1])))[[))], [0], [$2], [$3])])
 # Rather than expand m4_defn every time AS_LITERAL_IF is expanded, we
 # inline its expansion up front.
 m4_define([AS_LITERAL_IF],
-[m4_cond([m4_eval(m4_index(m4_quote($1), [@S|@]) == -1)], [0], [$3],
-        [m4_index(m4_translit(m4_quote($1),
-                              [[]`,#]]]dnl
-m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[,
-                              [$$$]),
-                  [$])], [-1], [$2],
-        [$3])])
+[m4_if(m4_cond([m4_eval(m4_index(m4_quote($1), [@S|@]) == -1)], [0], [],
+  [m4_index(m4_translit(m4_quote($1), [[]`,#]]]dnl
+m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[, [$$$]), [$])],
+  [-1], [-]), [-], [$2], [$3])])
 
 
 # AS_TMPDIR(PREFIX, [DIRECTORY = $TMPDIR [= /tmp]])
@@ -1909,9 +1906,9 @@ m4_define([AS_VAR_GET],
 # Polymorphic, and avoids sh expansion error upon interrupt or term signal.
 m4_define([AS_VAR_IF],
 [AS_LITERAL_IF([$1],
-  [AS_IF([test "x$$1" = x""$2], [$3], [$4])],
+  [AS_IF([test "x$$1" = x""$2]],
   [AS_VAR_COPY([as_val], [$1])
-   AS_IF([test "x$as_val" = x""$2], [$3], [$4])])])
+   AS_IF([test "x$as_val" = x""$2]]), [$3], [$4])])
 
 
 # AS_VAR_PUSHDEF and AS_VAR_POPDEF