From: Vladimír Čunát Date: Sun, 17 Dec 2023 08:17:39 +0000 (+0100) Subject: WIP ss16bit_simd: refactor load_found X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=231ed0c29;p=thirdparty%2Fknot-dns.git WIP ss16bit_simd: refactor load_found This also affects the return value in some less common cases. --- diff --git a/src/knot/modules/rrl/kru_ss16bit.c b/src/knot/modules/rrl/kru_ss16bit.c index e56138812c..d3bb945f31 100644 --- a/src/knot/modules/rrl/kru_ss16bit.c +++ b/src/knot/modules/rrl/kru_ss16bit.c @@ -207,17 +207,8 @@ bool kru_limited(struct kru *kru, void *buf, size_t buf_len, uint32_t time_now, } #endif - if (load) { - load_found:; - const uint32_t limit = (1<<16) - price; - if (*load >= limit) return true; - if (__builtin_add_overflow(*load, price, load)) { - *load = (1<<16) - 1; - return true; - } else { - return false; - } - } + if (load) + goto load_found; // No match, so find position of the smallest load. int min_li = 0; @@ -271,9 +262,15 @@ bool kru_limited(struct kru *kru, void *buf, size_t buf_len, uint32_t time_now, l[min_li]->ids[min_i] = id; load = &l[min_li]->loads[min_i]; // TODO: goto load_found? - if (__builtin_add_overflow(*load, price, load)) +load_found:; + const uint32_t limit = (1<<16) - price; + if (*load >= limit) return true; + if (__builtin_add_overflow(*load, price, load)) { *load = (1<<16) - 1; - return false; // Let's not limit it, though its questionable. + return true; + } else { + return false; + } } #ifdef __clang__