[PATCH v3 4/4] autoconf: prefer an unrolled loop for trivial AC_CHECK_FUNCS

Eric Blake <[email protected]>
Newsgroups gmane.comp.sysutils.autoconf.patches
Message-ID <[email protected]>
From: Paolo Bonzini <[email protected]>

An unrolled loop avoids the cost of spawning sed in AS_TR_SH and
AS_TR_CPP.  Prefer it if there is nothing in the second and third
argument of AC_CHECK_FUNCS and the first argument is a literal.

* lib/autoconf/functions.m4 (AC_CHECK_FUNCS): Unroll loop if safe.
(_AC_CHECK_FUNCS): Move basic implementation here.

Signed-off-by: Paolo Bonzini <[email protected]>
Message-Id: <[email protected]>
[eblake: perform AC_CHECK_FUNCS_ONCE changes separately, use
dnl to reduce generated blank lines]
Signed-off-by: Eric Blake <[email protected]>
---
 lib/autoconf/functions.m4 | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4
index 76824a2..a227cd4 100644
--- a/lib/autoconf/functions.m4
+++ b/lib/autoconf/functions.m4
@@ -88,12 +88,17 @@ m4_define([_AH_CHECK_FUNC],
 # `break' to stop the search.
 AC_DEFUN([AC_CHECK_FUNCS],
 [m4_map_args_w([$1], [_AH_CHECK_FUNC(], [)])]dnl
-[AS_FOR([AC_func], [ac_func], [$1],
-[AC_CHECK_FUNC(AC_func,
-	       [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_]AC_func)) $2],
-	       [$3])dnl])
+[m4_if([$2$3]AS_LITERAL_IF([$1], [[yes]], [[no]]), [yes],
+       [m4_map_args_w([$1], [_$0(], [)])],
+       [AS_FOR([AC_func], [ac_func], [$1], [_$0(AC_func, [$2], [$3])])])dnl
 ])# AC_CHECK_FUNCS

+m4_define([_AC_CHECK_FUNCS],
+[AC_CHECK_FUNC([$1],
+	       [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_]$1)) $2],
+	       [$3])dnl
+])
+

 # _AC_CHECK_FUNC_ONCE(FUNCTION)
 # -----------------------------
-- 
2.7.4
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.