From 61a72064b0269ff3443fff3bfbe098de458605ca Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 20 Jun 2014 07:15:34 -0700 Subject: 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. --- ChangeLog | 12 ++++++++++++ lib.c | 10 +++++----- match.c | 2 +- parser.y | 2 +- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index bb8884cb..52cad4b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2014-06-20 Kaz Kylheku + + 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 * eval.c (do_apf, apf): New functions. 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; } -- cgit v1.2.3