[16/18] argv_ref speedup: cache frequently used quotes
Eric Blake <[email protected]>
| Newsgroups | gmane.comp.gnu.m4.patches |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Next in the series. No dramatic speedups, but enough that it was worth doing. Rather than always copying string pairs, it was worth caching frequently used ones. In particular, since quote_age is encoded as the current 1-byte quote delimiters, it can double as the cache without any extra storage. I also consolidated the various argument printing routines, so that a tweak in one function gives consistent results to all the callers, rather than hunting down the multiple places where an argv object needs printing (when doing tracing, when an embedded $@ ref is flattened, when doing builtins such as errprint...). I had to add a test of -l behavior, since an earlier version of the patch caused a regression in how trace output displayed when -l was active. Finally, I implemented a todo in input.c to allow more efficient m4wrap text collection in place, rather than copying a flattened string; this will be handy in later patches when m4wrap is converted to POSIX FIFO ordering. 2008-02-21 Eric Blake <[email protected]> Stage 16: cache quotes and improve arg_print. Cache rather than always copying quotes when pushing $@ refs; in particular, reconstruct single-byte quotes on the fly. Allow NUL through m4wrap. Improve sharing of code that prints arguments. Memory impact: slight improvement, due to cached quotes. Speed impact: slight improvement, due to less copying. * src/m4.h (push_wrapup_init, push_wrapup_finish, quote_cache) (func_print): New prototypes. (arg_print): Adjust prototype. * src/builtin.h (func_print): New function. (define_user_macro): Slight cleanup. (dump_args): Delete, no longer used. (m4_errprint): Use arg_print. (m4_m4wrap): Handle embedded NUL. * src/debug.c (trace_pre): Use arg_print. * src/input.c (cached_quote): New variable. (push_wrapup): Split... (push_wrapup_init, push_wrapup_finish): ...into these. (input_print): Use arg_print. (quote_cache): New function. (pop_input, next_char_1, append_quote_token, set_quote_age): Adjust users. * src/macro.c (arg_text, make_argv_ref_token): Adjust users. (arg_print): Add parameters. * examples/null.m4: Test for NUL in m4wrap. * examples/null.out: Update expected output. * doc/m4.texinfo (Debug Levels): Test --arglength truncation. - -- Don't work too hard, make some time for fun as well! Eric Blake [email protected] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHvYXR84KuGfSFAYARAmV6AJ9dSxzjV8GsM04XD03cm5gRO9aPuACfc8uA TQ43YMozSg5cSf7YvAhSSQg= =KamW -----END PGP SIGNATURE----- _______________________________________________ M4-patches mailing list [email protected] http://lists.gnu.org/mailman/listinfo/m4-patches
m4.patch321
(text/plain, 60.3 KB) - not displayed