aboutsummaryrefslogtreecommitdiff
path: root/src/crunch.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/crunch.c')
-rw-r--r--src/crunch.c12
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) {