summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-10-25 07:44:35 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-10-25 07:44:35 -0700
commit00f5d2881b7a1b4daf91b80de60009d36182270e (patch)
treefcec590917302a799d52b40e67fc3bb32f0827ab /lib.c
parent61ced41f38712e1fc3350480a9812f49bc7de33f (diff)
downloadtxr-00f5d2881b7a1b4daf91b80de60009d36182270e.tar.gz
txr-00f5d2881b7a1b4daf91b80de60009d36182270e.tar.bz2
txr-00f5d2881b7a1b4daf91b80de60009d36182270e.zip
parser: use faster, unsafe nreverse.
* lib.c (us_nreverse): New function. * lib.h (us_nreverse): Declared. * parser.y (clauses_opt, n_exprs, r_exprs): Use us_nreverse instead of nreverse to rorder lists built in reverse into final shape.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index c288c8fc..4883f37d 100644
--- a/lib.c
+++ b/lib.c
@@ -1349,6 +1349,20 @@ val reverse(val seq_in)
}
}
+val us_nreverse(val in)
+{
+ val rev = nil;
+
+ while (in) {
+ val temp = us_cdr(in);
+ us_rplacd(in, rev);
+ rev = in;
+ in = temp;
+ }
+
+ return rev;
+}
+
val append2(val list1, val list2)
{
list_collect_decl (out, ptail);