Eric Blake <ebb9 <at> byu.net> writes: > The trick is recognizing that for a small conversion > set, the overhead of creating a 256-byte map and processing one byte at a > time is large compared to searching a word at a time for just the bytes > that need processing.
It helps if I don't introduce regressions when the second argument is empty: >From ccc1379c1360edc29e6f8d3ee3a88756e4fe1b44 Mon Sep 17 00:00:00 2001 From: Eric Blake <[email protected]> Date: Thu, 19 Feb 2009 16:26:55 -0700 Subject: [PATCH] Fix regression in translit. * src/builtin.c (m4_translit): Use correct comparison. * doc/m4.texinfo (Translit): Enhance test. Signed-off-by: Eric Blake <[email protected]> --- ChangeLog | 8 +++++++- doc/m4.texinfo | 6 ++++++ src/builtin.c | 4 ++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index edff0b8..1124a5e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,8 @@ -2009-02-18 Eric Blake <[email protected]> +2009-02-19 Eric Blake <[email protected]> + + Fix regression in translit. + * src/builtin.c (m4_translit): Use correct comparison. + * doc/m4.texinfo (Translit): Enhance test. Speed up input engine, by searching for quotes by buffer. * src/input.c (struct input_block): Add end pointer to string. @@ -6,6 +10,8 @@ (next_token): For quotes, attempt a buffer search. * NEWS: Document this. +2009-02-18 Eric Blake <[email protected]> + Speed up translit when from argument is short. * m4/gnulib-cache.m4: Import memchr2 module. * src/builtin.c (m4_translit): Use memchr2 when possible. diff --git a/doc/m4.texinfo b/doc/m4.texinfo index 10e63ef..6877ecc 100644 --- a/doc/m4.texinfo +++ b/doc/m4.texinfo @@ -5800,6 +5800,12 @@ Translit @result{}fgcdefgcde translit(`abcdeabcde', `ab', `ba') @result{}bacdebacde +translit(`abcdeabcde', `e', `f') +...@result{}abcdfabcdf +translit(`abc', `', `cde') +...@result{}abc +translit(`', `a', `bc') +...@result{} @end example @end ignore diff --git a/src/builtin.c b/src/builtin.c index 504075a..6378fb7 100644 --- a/src/builtin.c +++ b/src/builtin.c @@ -1824,10 +1824,10 @@ m4_translit (struct obstack *obs, int argc, token_data **argv) char found[UCHAR_MAX + 1]; unsigned char ch; - if (bad_argc (argv[0], argc, 3, 4) || !*from) + if (bad_argc (argv[0], argc, 3, 4) || !*data || !*from) { /* builtin(`translit') is blank, but translit(`abc') is abc. */ - if (argc <= 2) + if (2 <= argc) obstack_grow (obs, data, strlen (data)); return; } -- 1.6.1.2 _______________________________________________ M4-patches mailing list [email protected] http://lists.gnu.org/mailman/listinfo/m4-patches
