From 98ed59198be3104e82c00734e01f4a1022440d1b Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 7 Sep 2021 07:14:02 -0700 Subject: string-extend: third optional argument. A Boolean optional argument to string-extend indicates whether this is likely the last call to string-extend, so memory can be trimmed accordingly. * eval.c (eval_init): Update string-extend registration. * filter.c (trie_filter_string): Pass nil for new argument of string_extend. * lib.c (str_seq, replace_str, lazy_str_force, lazy_str_force_upto): Pass nil for new argument of string_extend. (rem_impl, remove_if, separate): Pass t for new argument of string_extend on last iteration, nil otherwise. (string_extend): Implement new third argument, defaulted to nil. Switch from chk_grow_vec to the more specific chk_wrealloc, which simplifies the code. * lib.h (string_extend): Declaration updated. * parser.y (litchars): Pass t as last argument of string_extend since we know syntactically that these reductions finalize the string. (restlitchar): Pass nil as the last argument of string_extend, since we know syntactically that it isn't the last. * regex.c (scan_until_common): Pass nil for new argument of string_extend. * txr.1: Documented. --- lib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib.h') diff --git a/lib.h b/lib.h index be62cf21..4c6993e6 100644 --- a/lib.h +++ b/lib.h @@ -884,7 +884,7 @@ val init_str(val str, const wchar_t *, val self); val copy_str(val str); val upcase_str(val str); val downcase_str(val str); -val string_extend(val str, val tail); +val string_extend(val str, val tail, val finish); val stringp(val str); val lazy_stringp(val str); val length_str(val str); -- cgit v1.2.3