summaryrefslogtreecommitdiffstats
path: root/args.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-03-23 06:08:45 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-03-23 06:08:45 -0700
commit3d27521df2a8174eb470a30ce6c4fd84b7d61464 (patch)
tree27a05115ae6469a11b7ed6bdc8e362ac5a07484f /args.c
parent2a8b1e4388daa00005cbc1e25913479075507ab2 (diff)
downloadtxr-3d27521df2a8174eb470a30ce6c4fd84b7d61464.tar.gz
txr-3d27521df2a8174eb470a30ce6c4fd84b7d61464.tar.bz2
txr-3d27521df2a8174eb470a30ce6c4fd84b7d61464.zip
umethod: use new dynamic args to avoid consing list.
* args.c (args_cat): New function. * args.h (args_cat): Declared. * struct.c (umethod_args_fun): env parameter is now a dynamic args object. Code adjusted accordingly. (umethod): Duplicate the args into a dynamic args object instead of consing up a list and also eliminate the temporary cons since we can pass the additional argument using the car field of the dynamic args.
Diffstat (limited to 'args.c')
-rw-r--r--args.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/args.c b/args.c
index 22c9fadd..cb8c062b 100644
--- a/args.c
+++ b/args.c
@@ -97,6 +97,15 @@ struct args *args_copy_zap(struct args *to, struct args *from)
return to;
}
+struct args *args_cat(struct args *to, struct args *from)
+{
+ size_t size = sizeof *from->arg * from->fill;
+ to->list = from->list;
+ memcpy(to->arg + to->fill, from->arg, size);
+ to->fill += from->fill;
+ return to;
+}
+
struct args *args_cat_zap(struct args *to, struct args *from)
{
size_t size = sizeof *from->arg * from->fill;