From c5134a9ddba4fd14703d506b0cccd51d823e013e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 30 May 2020 07:38:12 -0700 Subject: quasistrings: reduce consing. Quasistrings compile to code that requires on the sys:fmt-join function to glue strings together. Rewriting that function to avoid converting its arguments from struct args * to a list. * eval.c (fmt_join): Static function removed. * lib.c (cat_str_measure, cat_str_append): more_p parameter changed to int type, which better matches the C style Boolean values it takes. (fmt_join): New external function. * lib.h: Declared. * args.h (args_more_nozap, args_get_nozap): New inline functions allowing multiple iterations over arguments without making a copy. --- args.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'args.h') diff --git a/args.h b/args.h index c1455fd6..54c00bf2 100644 --- a/args.h +++ b/args.h @@ -130,6 +130,11 @@ INLINE int args_two_more(struct args *args, cnum index) cdr(args->list); } +INLINE int args_more_nozap(struct args *args, cnum index, val list) +{ + return list || index < args->fill; +} + void args_normalize_exact(struct args *args, cnum fill); void args_normalize_least(struct args *args, cnum fill); void args_normalize_fill(struct args *args, cnum minfill, cnum maxfill); @@ -173,6 +178,13 @@ INLINE val args_get(struct args *args, cnum *arg_index) return pop(&args->list); } +INLINE val args_get_nozap(struct args *args, cnum *arg_index, val *list) +{ + if (*arg_index < args->fill) + return args->arg[(*arg_index)++]; + return pop(list); +} + INLINE cnum args_count(struct args *args) { return args->fill + c_num(length_list(args->list)); -- cgit v1.2.3