From 2282c1bc60a9b37ca8b7fcf843a62413e328e324 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 7 Jan 2018 01:51:02 -0800 Subject: tail: reduce calls to cdr. * lib.c (tail): Don't call cdr on the same cell twice in the loop body. tail is used in list_collect and friends, which are used all over the place. --- lib.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib.c b/lib.c index 48bf1807..a318aecc 100644 --- a/lib.c +++ b/lib.c @@ -655,8 +655,9 @@ val listref(val list, val ind) loc tail(val cons) { - while (consp(cdr(cons))) - cons = cdr(cons); + val d; + for (d = cdr(cons); consp(d); d = cdr(d)) + cons = d; return cdr_l(cons); } -- cgit v1.2.3