[12/18] argv_ref speedup: several code cleanups

Eric Blake <[email protected]>
Newsgroups gmane.comp.gnu.m4.patches
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Next in the series.  This focuses on three general code cleanups that made
later patches in the series easier.  First - make token_chain a
discriminated union (smaller struct with fewer fields to initialize per
use, and the ability to add new union types rather than a binary decision
of string vs $@ reference).  Second - make passing quotes around simpler
(a single struct, with contents and lengths, which will make embedded NUL
in quotes easier to manage, and avoids some strlen).  Third - add a new
macro for the common case of calling arg_len (a later patch adds a
parameter that is typically false; besides, with embedded NUL, the length
becomes a much more important query).  On the master branch, I took the
time to split this into three commits, but since it was one commit in the
argv_ref series, and since some of the hunks overlap, I left it that way
for branch-1_4.  There is a slight memory savings due to a smaller struct,
and a negligible net speed penalty due to added code such as new quote
handling.

2008-01-26  Eric Blake  <[email protected]>

	Stage 12: make token_chain a union, add string_pair.
	Shrink size of symbol chains by using a union.  Make passing quote
	delimiters around more efficient.  Other code cleanups.
	Memory impact: slight improvement, due to smaller struct.
	Speed impact: slight penalty, due to more bookkeeping.
	* src/m4.h (STRING): Delete typedef.
	(struct string_pair, enum token_chain_type): New types.
	(struct token_chain): Reduce size via a union.
	(ARG_LEN): New macro.
	(ARG): Move here...
	* src/builtin.c (ARG): ...from here.
	(dump_args, define_macro, m4_dumpdef, m4_builtin, m4_indir)
	(m4_defn, mkstemp_helper, m4_maketemp, m4_mkstemp, m4___file__)
	(m4___program__, m4_m4wrap, m4_len, m4_index, m4_substr)
	(m4_regexp, m4_patsubst): Adjust callers.
	* src/input.c (rquote, lquote, bcomm, ecomm): Delete...
	(curr_quote, curr_comm): ...replaced by these.
	(make_text_link, push_token, pop_input, input_print, peek_input)
	(next_char_1, input_init, set_quotes, set_comment, set_quote_age)
	(next_token, peek_token): Adjust callers.
	* src/macro.c (expand_macro, arg_token, arg_mark, arg_text)
	(arg_equal, arg_len, make_argv_ref, push_arg, push_args):
	Likewise.
	* src/format.c (ARG_INT, ARG_LONG, ARG_STR, ARG_DOUBLE, format):
	Likewise.
	* src/freeze.c (produce_frozen_state): Likewise.
	* src/debug.c (trace_format, trace_pre): Likewise.
	(debug_decode): Don't lose partial traces prior to reducing
	debugmode.

- --
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

iD8DBQFHmuC884KuGfSFAYARAjpMAKCrnciqgfVV8Sld4Kc1OOFANlp4pACgnY0U
/7/ej+YFnmewMvk8VqGeZEo=
=lnQU
-----END PGP SIGNATURE-----

_______________________________________________
M4-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/m4-patches
m4.patch312 (text/plain, 117.8 KB) - not displayed
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.