summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-06-20 07:15:34 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-06-20 07:15:34 -0700
commit61a72064b0269ff3443fff3bfbe098de458605ca (patch)
treec1153ddc4ff04b35031aedf5ff5358a2511062da
parente21a452a9c75074ab7eff33b70950aecf3f3c309 (diff)
downloadtxr-61a72064b0269ff3443fff3bfbe098de458605ca.tar.gz
txr-61a72064b0269ff3443fff3bfbe098de458605ca.tar.bz2
txr-61a72064b0269ff3443fff3bfbe098de458605ca.zip
Optimization: add missing tail updates to some list
collecting loops. * lib.c (tuples_func, where, sel): Catch return value of list_collect and update tail variable. * match.c (do_txeval): Likewise. * parser.y (expand_meta): Likewise for list_collect_nconc.
-rw-r--r--ChangeLog12
-rw-r--r--lib.c10
-rw-r--r--match.c2
-rw-r--r--parser.y2
4 files changed, 19 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index bb8884cb..52cad4b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2014-06-20 Kaz Kylheku <kaz@kylheku.com>
+ Optimization: add missing tail updates to some list
+ collecting loops.
+
+ * lib.c (tuples_func, where, sel): Catch return value of
+ list_collect and update tail variable.
+
+ * match.c (do_txeval): Likewise.
+
+ * parser.y (expand_meta): Likewise for list_collect_nconc.
+
+2014-06-20 Kaz Kylheku <kaz@kylheku.com>
+
* eval.c (do_apf, apf): New functions.
(eval_init): Register apf as intrinsic.
diff --git a/lib.c b/lib.c
index b3b808ed..61390692 100644
--- a/lib.c
+++ b/lib.c
@@ -1297,11 +1297,11 @@ static val tuples_func(val env, val lcons)
val count;
for (count = n; count != zero && seq; count = minus(count, one))
- list_collect(ptail, pop(&seq));
+ ptail = list_collect(ptail, pop(&seq));
if (!missingp(fill))
for (; gt(count, zero); count = minus(count, one))
- list_collect(ptail, fill);
+ ptail = list_collect(ptail, fill);
rplaca(env, seq);
@@ -5484,7 +5484,7 @@ val where(val seq_in, val func)
for (; seq; seq = cdr(seq), idx = plus(idx, one)) {
val elt = car(seq);
if (funcall1(func, elt))
- list_collect(ptail, idx);
+ ptail = list_collect(ptail, idx);
}
return out;
@@ -5513,7 +5513,7 @@ val sel(val seq_in, val where_in)
} while (lt(wh, idx));
if (eql(wh, idx))
- list_collect (ptail, car(seq));
+ ptail = list_collect (ptail, car(seq));
}
}
break;
@@ -5524,7 +5524,7 @@ val sel(val seq_in, val where_in)
val wh = car(where);
if (ge(wh, len))
break;
- list_collect (ptail, ref(seq, car(where)));
+ ptail = list_collect (ptail, ref(seq, car(where)));
}
}
break;
diff --git a/match.c b/match.c
index e393e9b3..7a3e06c7 100644
--- a/match.c
+++ b/match.c
@@ -1464,7 +1464,7 @@ static val do_txeval(val spec, val form, val bindings, val allow_unbound)
list_collect_decl (out, tail);
uw_set_match_context(cons(spec, bindings));
for (iter = rest(form); iter != nil; iter = cdr(iter))
- list_collect(tail, subst_vars(cdr(car(iter)), bindings, nil));
+ tail = list_collect(tail, subst_vars(cdr(car(iter)), bindings, nil));
ret = out;
uw_env_end;
} else if (regexp(sym)) {
diff --git a/parser.y b/parser.y
index cda1aaf8..1266157d 100644
--- a/parser.y
+++ b/parser.y
@@ -1226,7 +1226,7 @@ static val expand_meta(val form, val menv)
ptail = nptail;
}
- list_collect_nconc(ptail, form);
+ ptail = list_collect_nconc(ptail, form);
return out;
}