mirror of
git://git.sv.gnu.org/autoconf
synced 2025-02-11 13:51:04 +08:00
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. Signed-off-by: Eric Blake <ebb9@byu.net>
This commit is contained in:
parent
7113f1b07c
commit
57e51969f0
@ -1,5 +1,9 @@
|
||||
2007-10-02 Eric Blake <ebb9@byu.net>
|
||||
|
||||
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.
|
||||
|
||||
Optimize AC_PREREQ and other m4sugar numerics.
|
||||
* lib/m4sugar/m4sugar.m4 (m4_sign): Write with m4_eval.
|
||||
(m4_cmp): Compare arbitrary expressions, without overflow.
|
||||
|
@ -551,9 +551,16 @@ m4_define([m4_noquote],
|
||||
# m4_shiftn(N, ...)
|
||||
# -----------------
|
||||
# Returns ... shifted N times. Useful for recursive "varargs" constructs.
|
||||
#
|
||||
# Internally, other m4sugar macros frequently use m4_shiftn(2, $@) and
|
||||
# m4_shiftn(3, $@). Optimize these cases to avoid extra recursion and
|
||||
# expansion.
|
||||
m4_define([m4_shiftn],
|
||||
[m4_assert(($1 >= 0) && ($# > $1))dnl
|
||||
_m4_shiftn($@)])
|
||||
[m4_if(m4_eval(($1 >= 0) && ($# > $1)), 0,
|
||||
[m4_assert(($1 >= 0) && ($# > $1))],
|
||||
[$1], 2, [m4_shift(m4_shift(m4_shift($@)))],
|
||||
[$1], 3, [m4_shift(m4_shift(m4_shift(m4_shift($@))))],
|
||||
[_m4_shiftn($@)])])
|
||||
|
||||
m4_define([_m4_shiftn],
|
||||
[m4_if([$1], 0,
|
||||
|
Loading…
Reference in New Issue
Block a user