From a08710ed0cb5ae8850f2f184c3cf25959d3008b6 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 18 Aug 2026 17:45:22 +0300 Subject: [PATCH] Small parsing speed improvement. --- parse.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/parse.c b/parse.c index 14608be..1d59d1f 100644 --- a/parse.c +++ b/parse.c @@ -217,6 +217,7 @@ Node *pa2stat(Node *a, Node *b, Node *c) /* pat, pat {...} */ Node *linkum(Node *a, Node *b) { Node *c; + static Node *prev_head, *prev_tail; /* auto-init to NULL */ if (errorflag) /* don't link things that are wrong */ return a; @@ -224,9 +225,17 @@ Node *linkum(Node *a, Node *b) return(b); else if (b == NULL) return(a); - for (c = a; c->nnext != NULL; c = c->nnext) - ; - c->nnext = b; + + if (prev_head == a) { + prev_tail->nnext = b; + prev_tail = b; + } else { + for (c = a; c->nnext != NULL; c = c->nnext) + ; + c->nnext = b; + prev_head = a; + prev_tail = b; + } return(a); }