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 (#1557)

A trival pr, move maxlen check outside to reduce unnecessary ecks

---------

Signed-off-by: hengyouhai <[email protected]>
Signed-off-by: 烈香 <[email protected]>
Co-authored-by: hengyouhai <[email protected]>
  • Loading branch information
hengyoush and hengyouhai authored Feb 1, 2025
1 parent 78bcc0a commit 26c6f1a
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 @@ -2213,11 +2213,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 26c6f1a

Please sign in to comment.