From 1a1ee72ec1266d0f0f806378715c274c9879ff14 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Tue, 21 Mar 2000 12:09:31 +0000 Subject: [PATCH] Speed ups. * libm4.m4 (m4_append, m4_list_append): Use m4_define, not define. On my machine the former implementation takes 4mn 40s to run the test suite. Using m4_define leads to 4mn 15s. * acgeneral.m4 (_AC_SUBST): Use AC_EXPAND_ONCE (which uses m4_define, not define). 4mn. (_AC_DIVERT): Don't use m4_case. Starting from those 4mn, if you just move NORMAL* first in m4_case, the test suite is run in 3mn. If instead of using m4, you use an `associative array' plus a wrapper (current implementation), it falls to 2mn. --- ChangeLog | 14 +++++++++++ acgeneral.m4 | 56 +++++++++++++++++++++-------------------- lib/autoconf/general.m4 | 56 +++++++++++++++++++++-------------------- libm4.m4 | 4 +-- 4 files changed, 74 insertions(+), 56 deletions(-) diff --git a/ChangeLog b/ChangeLog index cbf89ddd..3e679432 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2000-03-21 Akim Demaille + + Speed ups. + + * libm4.m4 (m4_append, m4_list_append): Use m4_define, not define. + On my machine the former implementation takes 4mn 40s to run the + test suite. Using m4_define leads to 4mn 15s. + * acgeneral.m4 (_AC_SUBST): Use AC_EXPAND_ONCE (which uses + m4_define, not define). 4mn. + (_AC_DIVERT): Don't use m4_case. Starting from those 4mn, if you + just move NORMAL* first in m4_case, the test suite is run in 3mn. + If instead of using m4, you use an `associative array' plus a + wrapper (current implementation), it falls to 2mn. + 2000-03-21 Akim Demaille * tests/tools.m4 (autoconf --trace): New test. diff --git a/acgeneral.m4 b/acgeneral.m4 index 2fd84613..11d9b72e 100644 --- a/acgeneral.m4 +++ b/acgeneral.m4 @@ -111,30 +111,33 @@ m4_namespace_push(autoconf) # -------------------------- # Convert a diversion name into its number. Otherwise, return # DIVERSION-NAME which is supposed to be an actual diversion number. +# Of course it would be nicer to use m4_case here, instead of zillions +# of little macros, but it then takes twice longer to run `autoconf'! +define([_AC_DIVERT(KILL)], -1) + +define([_AC_DIVERT(BINSH)], 0) +define([_AC_DIVERT(NOTICE)], 1) +define([_AC_DIVERT(DEFAULTS)], 2) +define([_AC_DIVERT(INIT_PARSE_ARGS)], 3) +define([_AC_DIVERT(HELP_BEGIN)], 4) +define([_AC_DIVERT(HELP_ENABLE)], 5) +define([_AC_DIVERT(HELP_WITH)], 6) +define([_AC_DIVERT(HELP_VAR)], 7) +define([_AC_DIVERT(HELP_END)], 8) +define([_AC_DIVERT(VERSION_BEGIN)], 9) +define([_AC_DIVERT(VERSION_END)], 10) +define([_AC_DIVERT(INIT_PREPARE)], 11) + +define([_AC_DIVERT(NORMAL_4)], 20) +define([_AC_DIVERT(NORMAL_3)], 21) +define([_AC_DIVERT(NORMAL_2)], 22) +define([_AC_DIVERT(NORMAL_1)], 23) +define([_AC_DIVERT(NORMAL)], 24) + define([_AC_DIVERT], -[m4_case([$1], - [KILL], -1, - - [BINSH], 0, - [NOTICE], 1, - [DEFAULTS], 2, - [INIT_PARSE_ARGS], 3, - [HELP_BEGIN], 4, - [HELP_ENABLE], 5, - [HELP_WITH], 6, - [HELP_VAR], 7, - [HELP_END], 8, - [VERSION_BEGIN], 9, - [VERSION_END], 10, - [INIT_PREPARE], 11, - - [NORMAL_4], 20, - [NORMAL_3], 21, - [NORMAL_2], 22, - [NORMAL_1], 23, - [NORMAL], 24, - - [$1])]) +[ifdef([_AC_DIVERT($1)], + [indir([_AC_DIVERT($1)])], + [$1])]) # AC_DIVERT_PUSH(DIVERSION-NAME) @@ -1895,11 +1898,10 @@ EOF # If VARIABLE has not already been AC_SUBST'ed, append the sed PROGRAM # to `_AC_SUBST_SED_PROGRAM'. define(_AC_SUBST, -[ifdef([AC_SUBST($1)], [], -[define([AC_SUBST($1)])dnl -m4_append([_AC_SUBST_SED_PROGRAM], +[AC_EXPAND_ONCE([m4_append([_AC_SUBST_SED_PROGRAM], [$2 -])])]) +])])dnl +]) # Initialize. define([_AC_SUBST_SED_PROGRAM]) diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index 2fd84613..11d9b72e 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -111,30 +111,33 @@ m4_namespace_push(autoconf) # -------------------------- # Convert a diversion name into its number. Otherwise, return # DIVERSION-NAME which is supposed to be an actual diversion number. +# Of course it would be nicer to use m4_case here, instead of zillions +# of little macros, but it then takes twice longer to run `autoconf'! +define([_AC_DIVERT(KILL)], -1) + +define([_AC_DIVERT(BINSH)], 0) +define([_AC_DIVERT(NOTICE)], 1) +define([_AC_DIVERT(DEFAULTS)], 2) +define([_AC_DIVERT(INIT_PARSE_ARGS)], 3) +define([_AC_DIVERT(HELP_BEGIN)], 4) +define([_AC_DIVERT(HELP_ENABLE)], 5) +define([_AC_DIVERT(HELP_WITH)], 6) +define([_AC_DIVERT(HELP_VAR)], 7) +define([_AC_DIVERT(HELP_END)], 8) +define([_AC_DIVERT(VERSION_BEGIN)], 9) +define([_AC_DIVERT(VERSION_END)], 10) +define([_AC_DIVERT(INIT_PREPARE)], 11) + +define([_AC_DIVERT(NORMAL_4)], 20) +define([_AC_DIVERT(NORMAL_3)], 21) +define([_AC_DIVERT(NORMAL_2)], 22) +define([_AC_DIVERT(NORMAL_1)], 23) +define([_AC_DIVERT(NORMAL)], 24) + define([_AC_DIVERT], -[m4_case([$1], - [KILL], -1, - - [BINSH], 0, - [NOTICE], 1, - [DEFAULTS], 2, - [INIT_PARSE_ARGS], 3, - [HELP_BEGIN], 4, - [HELP_ENABLE], 5, - [HELP_WITH], 6, - [HELP_VAR], 7, - [HELP_END], 8, - [VERSION_BEGIN], 9, - [VERSION_END], 10, - [INIT_PREPARE], 11, - - [NORMAL_4], 20, - [NORMAL_3], 21, - [NORMAL_2], 22, - [NORMAL_1], 23, - [NORMAL], 24, - - [$1])]) +[ifdef([_AC_DIVERT($1)], + [indir([_AC_DIVERT($1)])], + [$1])]) # AC_DIVERT_PUSH(DIVERSION-NAME) @@ -1895,11 +1898,10 @@ EOF # If VARIABLE has not already been AC_SUBST'ed, append the sed PROGRAM # to `_AC_SUBST_SED_PROGRAM'. define(_AC_SUBST, -[ifdef([AC_SUBST($1)], [], -[define([AC_SUBST($1)])dnl -m4_append([_AC_SUBST_SED_PROGRAM], +[AC_EXPAND_ONCE([m4_append([_AC_SUBST_SED_PROGRAM], [$2 -])])]) +])])dnl +]) # Initialize. define([_AC_SUBST_SED_PROGRAM]) diff --git a/libm4.m4 b/libm4.m4 index b67a88df..19d9881b 100644 --- a/libm4.m4 +++ b/libm4.m4 @@ -634,7 +634,7 @@ define([m4_strip], # => # => active define(m4_append, -[define([$1], +[m4_define([$1], ifdef([$1], [defn([$1])])[$2])]) @@ -642,7 +642,7 @@ ifdef([$1], [defn([$1])])[$2])]) # ---------------------------------- # Same as `m4_append', but each element is separated by `, '. define(m4_list_append, -[define([$1], +[m4_define([$1], ifdef([$1], [defn([$1]), ])[$2])])