Skip to content

Commit

Permalink
Loop optimization: move maxlen check outside to reduce unnecessary ch…
Browse files Browse the repository at this point in the history
…ecks

Signed-off-by: hengyouhai <[email protected]>
  • Loading branch information
hengyouhai committed Jan 13, 2025
1 parent dc9ca1b commit e9dcb59
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/hashtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -2183,11 +2183,12 @@ int hashtableLongestBucketChain(hashtable *ht) {
int chainlen = 0;
bucket *b = &ht->tables[table][i];
while (b->chained) {
if (++chainlen > maxlen) {
maxlen = chainlen;
}
++chainlen
b = getChildBucket(b);
}
if (chainlen > maxlen) {
maxlen = chainlen;
}
}
}
return maxlen;
Expand Down

0 comments on commit e9dcb59

Please sign in to comment.