Eric Blake <ebb9 <at> byu.net> writes:
> >> Meanwhile, before I actually work on this patch, I noticed a small
optimization
> >> that I will be applying soon:
> >
> > Is this really worth it?...
>
> For coreutils, it cut "autoconf --trace 'm4_case:$%' | wc" from 24k to 6k
> of parameter size, which in turn means less parsing during the recursion
> helpers for m4_case. Unfortunately, I didn't measure pre- and post-
> timings to see if it was noticeable; however, I also suspect that m4 1.4.x
> sees a bigger improvement than m4.git branch-1.6 (where $@ handling is
> more efficient).
And a corresponding optimization for AC_CHECK_TYPE. For coreutils, it shaves
off 7k of text parsing, and 27 fewer m4_bmatch calls. Timing wise, it wasn't
much of a difference (AC_CHECK_TYPE is not as frequent as AC_CHECK_HEADER), but
we might as well be consistent. So I went ahead and committed this:
From: Eric Blake <[EMAIL PROTECTED]>
Date: Thu, 6 Nov 2008 16:29:53 -0700
Subject: [PATCH] Speed up AC_CHECK_TYPE.
* lib/autoconf/types.m4 (AC_CHECK_TYPE): Factor out $@, and avoid
regex when enough arguments are present.
Signed-off-by: Eric Blake <[EMAIL PROTECTED]>
---
ChangeLog | 6 ++++++
lib/autoconf/types.m4 | 21 ++++++++++-----------
2 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 37e69c7..34a61c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-11-06 Eric Blake <[EMAIL PROTECTED]>
+
+ Speed up AC_CHECK_TYPE.
+ * lib/autoconf/types.m4 (AC_CHECK_TYPE): Factor out $@, and avoid
+ regex when enough arguments are present.
+
2008-11-06 Paolo Bonzini <[EMAIL PROTECTED]>
Remove three forks per _AC_RUN_LOG_STDERR in the common case.
diff --git a/lib/autoconf/types.m4 b/lib/autoconf/types.m4
index 6360d40..b8fc81a 100644
--- a/lib/autoconf/types.m4
+++ b/lib/autoconf/types.m4
@@ -248,17 +248,16 @@ m4_define([_AC_CHECK_TYPE_MAYBE_TYPE_P],
# 3. $2 seems to be a type => NEW plus a warning
# 4. default => NEW
AC_DEFUN([AC_CHECK_TYPE],
-[m4_if($#, 3,
- [_AC_CHECK_TYPE_NEW($@)],
- $#, 4,
- [_AC_CHECK_TYPE_NEW($@)],
- _AC_CHECK_TYPE_REPLACEMENT_TYPE_P([$2]), 1,
- [_AC_CHECK_TYPE_OLD($@)],
- _AC_CHECK_TYPE_MAYBE_TYPE_P([$2]), 1,
- [AC_DIAGNOSE([syntax],
- [$0: assuming `$2' is not a type])_AC_CHECK_TYPE_NEW($@)],
- [_AC_CHECK_TYPE_NEW($@)])[]dnl
-])# AC_CHECK_TYPE
+[m4_cond([$#], [3],
+ [_AC_CHECK_TYPE_NEW],
+ [$#], [4],
+ [_AC_CHECK_TYPE_NEW],
+ [_AC_CHECK_TYPE_REPLACEMENT_TYPE_P([$2])], [1],
+ [_AC_CHECK_TYPE_OLD],
+ [_AC_CHECK_TYPE_MAYBE_TYPE_P([$2])], [1],
+ [AC_DIAGNOSE([syntax],
+ [$0: assuming `$2' is not a type])_AC_CHECK_TYPE_NEW],
+ [_AC_CHECK_TYPE_NEW])($@)])# AC_CHECK_TYPE
--
1.6.0.2