From 00f5d2881b7a1b4daf91b80de60009d36182270e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 25 Oct 2019 07:44:35 -0700 Subject: 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. --- parser.y | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'parser.y') diff --git a/parser.y b/parser.y index c77babc4..41fb965f 100644 --- a/parser.y +++ b/parser.y @@ -233,7 +233,7 @@ clauses_rev : clause { $$ = check_parse_time_action(cons($1, | clauses_rev clause { $$ = check_parse_time_action(cons($2, $1)); } ; -clauses_opt : clauses_rev { $$ = nreverse($1); } +clauses_opt : clauses_rev { $$ = us_nreverse($1); } | /* empty */ { $$ = nil; } ; @@ -932,7 +932,7 @@ exprs_opt : exprs { $$ = $1; } n_exprs : r_exprs { val term_atom = pop(&$1); val tail_cons = $1; - $$ = nreverse($1); + $$ = us_nreverse($1); if (term_atom != unique_s) rplacd(tail_cons, term_atom); } ; @@ -958,14 +958,14 @@ r_exprs : n_expr { val exprs = cons($1, nil); misplaced_consing_dot_check(scnr, term_atom_cons); rplaca(term_atom_cons, $3); $$ = $1; } - | WSPLICE wordslit { $$ = cons(unique_s, nreverse(rl($2, num($1)))); + | WSPLICE wordslit { $$ = cons(unique_s, us_nreverse(rl($2, num($1)))); rlc($$, cdr($$)); } | r_exprs WSPLICE wordslit { val term_atom_cons = $1; val exprs = cdr($1); misplaced_consing_dot_check(scnr, term_atom_cons); rplacd(term_atom_cons, - nappend2(rl(nreverse($3), num($2)), + nappend2(rl(us_nreverse($3), num($2)), exprs)); $$ = term_atom_cons; } | QWSPLICE wordsqlit { $$ = cons(unique_s, rl($2, num($1))); @@ -975,7 +975,7 @@ r_exprs : n_expr { val exprs = cons($1, nil); val exprs = cdr($1); misplaced_consing_dot_check(scnr, term_atom_cons); rplacd(term_atom_cons, - nappend2(rl(nreverse($3), num($2)), + nappend2(rl(us_nreverse($3), num($2)), exprs)); $$ = term_atom_cons; } ; -- cgit v1.2.3