diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-10-16 07:57:15 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-10-16 07:57:15 -0700 |
commit | e91d406a7ff82b8dfd57b3d84065597b640328db (patch) | |
tree | 763f4eb9a23d77efe9905c1accd3b2d77fec2b18 /lib.c | |
parent | 8c907a932436a8bdc2c52d2a28e14115df525654 (diff) | |
download | txr-e91d406a7ff82b8dfd57b3d84065597b640328db.tar.gz txr-e91d406a7ff82b8dfd57b3d84065597b640328db.tar.bz2 txr-e91d406a7ff82b8dfd57b3d84065597b640328db.zip |
copy-cons: more efficient; copies lconses.
* lib.c (copy_cons): Rewrite to copy the object in a more
low-level way, rather than going through the accessors
and constructors. Now copies LCONS as LCONS, including its
update function.
* txr.1: copy-cons re-documented.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -8160,9 +8160,19 @@ val alist_nremove1(val list, val key) return list; } -val copy_cons(val c) +val copy_cons(val cell) { - return cons(car(c), cdr(c)); + switch (type(cell)) { + case CONS: + case LCONS: + { + val obj = make_obj(); + *obj = *cell; + return obj; + } + default: + type_mismatch(lit("copy-cons: ~s is not a cons"), cell, nao); + } } val copy_alist(val list) |