]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Use m4_set_map_sep in more places.
authorEric Blake <ebb9@byu.net>
Wed, 5 Nov 2008 19:09:00 +0000 (12:09 -0700)
committerEric Blake <ebb9@byu.net>
Wed, 5 Nov 2008 20:31:46 +0000 (13:31 -0700)
* lib/m4sugar/m4sugar.m4 (m4_set_difference, m4_set_intersection)
(m4_set_union): Use m4_set_map_sep rather than m4_set_foreach.
* doc/autoconf.texi (Set manipulation Macros) <m4_set_map>:
Enhance documentation.
<m4_set_foreach>: Mention faster alternative.
(Looping constructs) <m4_foreach>: Likewise.

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

index d14b179f3b0e67f74b91ec1ae0e9548d97c293c8..73e80955e589ddf1318156878fe6526af6bacbde 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2008-11-05  Eric Blake  <ebb9@byu.net>
 
+       Use m4_set_map_sep in more places.
+       * lib/m4sugar/m4sugar.m4 (m4_set_difference, m4_set_intersection)
+       (m4_set_union): Use m4_set_map_sep rather than m4_set_foreach.
+       * doc/autoconf.texi (Set manipulation Macros) <m4_set_map>:
+       Enhance documentation.
+       <m4_set_foreach>: Mention faster alternative.
+       (Looping constructs) <m4_foreach>: Likewise.
+
        Unify m4_set_foreach and m4_set_map.
        * lib/m4sugar/m4sugar.m4 (m4_set_map_sep): New macro, undocumented
        for now.
index bc46d7710e7bdefcdbae056956c4f5c1145c896b..e1149923306d4267f533eeefcc7b5010cf29c97d 100644 (file)
@@ -10921,6 +10921,9 @@ m4_foreach([myvar], [[foo], [bar, baz]],
 @result{}echo foo
 @result{}echo bar, baz
 @end example
+
+Note that for some forms of @var{expression}, it may be faster to use
+@code{m4_map_args}.
 @end defmac
 
 @anchor{m4_foreach_w}
@@ -11786,7 +11789,8 @@ unspecified if @var{action} recursively lists the contents of @var{set}
 in any way other than removing the element currently contained in
 @var{variable}.  This macro is faster than the corresponding
 @code{m4_foreach([@var{variable}],
-m4_indir([m4_dquote]m4_set_listc([@var{set}])), [@var{action}])}.
+m4_indir([m4_dquote]m4_set_listc([@var{set}])), [@var{action}])},
+although @code{m4_set_map} might be faster still.
 
 @example
 m4_set_add_all([a]m4_for([i], [1], [5], [], [,i]))
@@ -11847,9 +11851,11 @@ For each element in the set @var{set}, expand @var{action} with a single
 argument of the set element.  Behavior is unspecified if @var{action}
 recursively lists the contents of @var{set} (although listing other sets
 is acceptable), or if it modifies the set in any way other than removing
-the element passed as an argument.  This macro is faster than the
-corresponding
-@code{m4_map_args([@var{action}]m4_set_listc([@var{set}]))}.
+the element passed as an argument.  This macro is faster than either
+corresponding counterpart of
+@code{m4_map_args([@var{action}]m4_set_listc([@var{set}]))} or
+@code{m4_set_foreach([@var{set}], [var],
+[@var{action}(m4_defn([var]))])}.
 @end defmac
 
 @defmac m4_set_remove (@var{set}, @var{value}, @ovar{if-present}, @
index 15fd807011198ba5b7c1556e7afcb102e4b27fb8..5c2e1c80cf2640fd175d9513344f29fa995841bb 100644 (file)
@@ -2744,12 +2744,12 @@ m4_define([m4_set_delete],
 # arguments, such as for m4_join, or wrapped inside quotes for use in
 # m4_foreach.  Order of the output is not guaranteed.
 #
-# Short-circuit the idempotence relation.  Use _m4_defn for speed.
+# Short-circuit the idempotence relation.
 m4_define([m4_set_difference],
-[m4_if([$1], [$2], [],
-       [m4_set_foreach([$1], [_m4_element],
-                      [m4_set_contains([$2], _m4_defn([_m4_element]), [],
-                                       [,_m4_defn([_m4_element])])])])])
+[m4_if([$1], [$2], [], [m4_set_map_sep([$1], [_$0([$2],], [)])])])
+
+m4_define([_m4_set_difference],
+[m4_set_contains([$1], [$2], [], [,[$2]])])
 
 # m4_set_dump(SET, [SEP])
 # -----------------------
@@ -2814,13 +2814,14 @@ m4_define([m4_set_foreach],
 # m4_foreach.  Order of the output is not guaranteed.
 #
 # Iterate over the smaller set, and short-circuit the idempotence
-# relation.  Use _m4_defn for speed.
+# relation.
 m4_define([m4_set_intersection],
 [m4_if([$1], [$2], [m4_set_listc([$1])],
        m4_eval(m4_set_size([$2]) < m4_set_size([$1])), [1], [$0([$2], [$1])],
-       [m4_set_foreach([$1], [_m4_element],
-                      [m4_set_contains([$2], _m4_defn([_m4_element]),
-                                       [,_m4_defn([_m4_element])])])])])
+       [m4_set_map_sep([$1], [_$0([$2],], [)])])])
+
+m4_define([_m4_set_intersection],
+[m4_set_contains([$1], [$2], [,[$2]])])
 
 # m4_set_list(SET)
 # m4_set_listc(SET)
@@ -2901,12 +2902,14 @@ m4_define([_m4_set_size],
 # not guaranteed.
 #
 # We can rely on the fact that m4_set_listc prunes SET1, so we don't
-# need to check _m4_set([$1],element) for 0.  Use _m4_defn for speed.
-# Short-circuit the idempotence relation.
+# need to check _m4_set([$1],element) for 0.  Short-circuit the
+# idempotence relation.
 m4_define([m4_set_union],
-[m4_set_listc([$1])m4_if([$1], [$2], [], [m4_set_foreach([$2], [_m4_element],
-  [m4_ifdef([_m4_set([$1],]_m4_defn([_m4_element])[)], [],
-           [,_m4_defn([_m4_element])])])])])
+[m4_set_listc([$1])m4_if([$1], [$2], [],
+  [m4_set_map_sep([$2], [_$0([$1],], [)])])])
+
+m4_define([_m4_set_union],
+[m4_ifdef([_m4_set([$1],$2)], [], [,[$2]])])
 
 
 ## ------------------- ##