summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-01-07 01:51:02 -0800
committerKaz Kylheku <kaz@kylheku.com>2018-01-07 01:51:02 -0800
commitca5440c579407ba9d572e41b3bab6031c71949a3 (patch)
tree75675a614945779c8805c1dc84928961b5a8ef55
parent6e9e8e07abfed921264c100297844dd5969d6e42 (diff)
downloadtxr-ca5440c579407ba9d572e41b3bab6031c71949a3.tar.gz
txr-ca5440c579407ba9d572e41b3bab6031c71949a3.tar.bz2
txr-ca5440c579407ba9d572e41b3bab6031c71949a3.zip
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.
-rw-r--r--lib.c5
1 files 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);
}