summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-04-22 06:59:21 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-04-22 06:59:21 -0700
commit819d7563931876430f6631cc07bf337c913394bc (patch)
tree032e0a97f78581eb27496e591eb76083a55cb637
parent51cdc93b40dbebd65b14e931385cb3bd354a8082 (diff)
downloadtxr-819d7563931876430f6631cc07bf337c913394bc.tar.gz
txr-819d7563931876430f6631cc07bf337c913394bc.tar.bz2
txr-819d7563931876430f6631cc07bf337c913394bc.zip
Recycle temporary list-of-lists in mapping functions.
* eval.c (mapcarv, mappendv, mapdov): When done, we can recycle the conses used for the temporary copy of the list-of-lists, whose car-s are used for iterating over the lists in paralle. This is safe because the temporary list's conses aren't shared with any other function.
-rw-r--r--eval.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/eval.c b/eval.c
index 73eaf95b..7c8d9b45 100644
--- a/eval.c
+++ b/eval.c
@@ -3749,8 +3749,10 @@ val mapcarv(val fun, struct args *lists)
for (iter = lofl; iter; iter = cdr(iter)) {
val list = car(iter);
- if (!list)
+ if (!list) {
+ rcyc_list(lofl);
return make_like(out, list_orig);
+ }
atail = list_collect(atail, car(list));
deref(car_l(iter)) = cdr(list);
}
@@ -3784,8 +3786,10 @@ static val mappendv(val fun, struct args *lists)
for (iter = lofl; iter; iter = cdr(iter)) {
val list = car(iter);
- if (!list)
+ if (!list) {
+ rcyc_list(lofl);
return make_like(out, list_orig);
+ }
atail = list_collect(atail, car(list));
deref(car_l(iter)) = cdr(list);
}
@@ -3877,8 +3881,10 @@ static val mapdov(val fun, struct args *lists)
for (iter = lofl; iter; iter = cdr(iter)) {
val list = car(iter);
- if (!list)
+ if (!list) {
+ rcyc_list(lofl);
return nil;
+ }
atail = list_collect(atail, car(list));
deref(car_l(iter)) = cdr(list);
}