From e9dcb59f52c6ab37cdcf9173b55a4fe8e6ac01f6 Mon Sep 17 00:00:00 2001 From: hengyouhai Date: Mon, 13 Jan 2025 21:35:11 +0800 Subject: [PATCH] Loop optimization: move maxlen check outside to reduce unnecessary checks Signed-off-by: hengyouhai --- src/hashtable.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hashtable.c b/src/hashtable.c index 3f1eff19c1..34185ae5c5 100644 --- a/src/hashtable.c +++ b/src/hashtable.c @@ -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;