diff options
| author | B. Watson <urchlay@slackware.uk> | 2025-12-07 05:44:27 -0500 |
|---|---|---|
| committer | B. Watson <urchlay@slackware.uk> | 2025-12-07 05:44:27 -0500 |
| commit | 8f15c4eb2dd0be83158b4546560b771f5554a166 (patch) | |
| tree | f6d7c44f7e07831307317c2be442eb004d19a50b | |
| parent | 2718ebef0c3a1dcaab74b567ba5726a9fa20fcdb (diff) | |
| download | alftools-8f15c4eb2dd0be83158b4546560b771f5554a166.tar.gz | |
alf: speed up compression by about 10%.
| -rw-r--r-- | src/crunch.c | 12 |
1 files 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) { |
