[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
m4_qlen speedup
From: |
Eric Blake |
Subject: |
m4_qlen speedup |
Date: |
Mon, 21 Jan 2008 20:32:44 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Phooey. I meant to commit this linearly (and after a review), but goofed up my
git repository and ended up pushing a merge instead. At any rate, the damage
is done (I don't feel like rewinding the master branch of savannah's git
repository), so here's what I committed. The idea here is that m4_qlen can be
done via a single builtin m4_patsubst, rather than a series of macro expansions
through the multi-level m4_patsubsts, making m4_qlen faster when quadrigraphs
are present. Or put another way, since we already have a regex with
alternation, we can use that alternation to our advantage rather than needing a
separate m4_if. However, thanks to my patch last year that avoids the regex
altogether if the string has no @ characters, the gains are not usually in a
hot path (for example, coreutils does not use quadrigraphs in its configure.ac).
From: Eric Blake <address@hidden>
Date: Tue, 15 Jan 2008 08:49:08 -0700
Subject: [PATCH] * lib/m4sugar/m4sugar.m4 (m4_qlen): Use fewer macros.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 4 ++++
lib/m4sugar/m4sugar.m4 | 9 +++++----
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 107d031..5f70b64 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-01-15 Eric Blake <address@hidden>
+
+ * lib/m4sugar/m4sugar.m4 (m4_qlen): Use fewer macros.
+
2008-01-08 Ralf Wildenhues <address@hidden>
* tests/Makefile.am (noinst_SCRIPTS): Renamed from
diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4
index c73a940..e831555 100644
--- a/lib/m4sugar/m4sugar.m4
+++ b/lib/m4sugar/m4sugar.m4
@@ -3,8 +3,8 @@ divert(-1)# -*-
Autoconf -*-
# Base M4 layer.
# Requires GNU M4.
#
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free
-# Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+# 2008 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -1760,7 +1760,7 @@ m4_define([m4_flatten],
# => active activeend
#
# First, notice that we guarantee trailing space. Why? Because regular
-# expressions are greedy, and `.* ?' would alway groups the space into the
+# expressions are greedy, and `.* ?' would always group the space into the
# .* portion. The algorithm is simpler by avoiding `?' at the end. The
# algorithm correctly strips everything if STRING is just ` '.
#
@@ -2032,7 +2032,8 @@ m4_builtin([popdef], [m4_Border])dnl
# Avoid bpatsubsts for the common case of no quadrigraphs.
m4_define([m4_qlen],
[m4_if(m4_index([$1], address@hidden), [-1], [m4_len([$1])],
- [m4_len(m4_bpatsubsts([[$1]], address@hidden(<:\|:>\|S|\|%:\)@], [P],
[@&address@hidden))])])
+ [m4_len(m4_bpatsubst([[$1]],
address@hidden(\(<:\|:>\|S|\|%:\)\(@\)\|&address@hidden)],
+ [\3]))])])
# m4_qdelta(STRING)
--
1.5.3.8
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- m4_qlen speedup,
Eric Blake <=