From 8f15c4eb2dd0be83158b4546560b771f5554a166 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sun, 7 Dec 2025 05:44:27 -0500 Subject: alf: speed up compression by about 10%. --- src/crunch.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/crunch.c b/src/crunch.c index 5f21223..315469b 100644 --- a/src/crunch.c +++ b/src/crunch.c @@ -194,19 +194,17 @@ token_t *new_token(u8 chr) { return newtok; } +/* since we're not sorting the kids, adding the new kid as the + head of the list is faster than walking the list to add it + to the tail. gives about a 10% speedup. */ void add_kid(token_t *oldtok, token_t *newtok) { - token_t *kid; - if(!oldtok->kids) { oldtok->kids = newtok; return; } - kid = oldtok->kids; - while(kid->sibling) - kid = kid->sibling; - - kid->sibling = newtok; + newtok->sibling = oldtok->kids; + oldtok->kids = newtok; } void make_token(token_t *oldtok, u8 newchr) { -- cgit v1.2.3