From: Willy Tarreau Date: Sat, 30 Dec 2023 15:28:05 +0000 (+0100) Subject: IMPORT: ebtree: make string_equal_bits turn back to unsigned char X-Git-Tag: v3.0-dev1~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a14f99dbb243df5bb29866285b0ce922b4198a1;p=thirdparty%2Fhaproxy.git IMPORT: ebtree: make string_equal_bits turn back to unsigned char With flsnz() instead of flsnz_long() we're now getting a better performance on both x86 and ARM. The difference is that previously we were relying on a function that was forcing the use of register %eax for the 8-bit version and that was preventing the compiler from keeping the code optimized. The gain is roughly 5% on ARM and 1% on x86. This is cbtree commit 19cf39b2514bea79fed94d85e421e293be097a0e. This is ebtree commit a9aaf2d94e2c92fa37aa3152c2ad8220a9533ead. --- diff --git a/include/import/ebtree.h b/include/import/ebtree.h index 25eb85cfbe..c7a9a3897a 100644 --- a/include/import/ebtree.h +++ b/include/import/ebtree.h @@ -840,7 +840,7 @@ static forceinline ssize_t string_equal_bits(const unsigned char *a, const unsigned char *b, size_t ignore) { - unsigned long c, d; + unsigned char c, d; size_t beg; beg = ignore >> 3; @@ -864,7 +864,7 @@ static forceinline ssize_t string_equal_bits(const unsigned char *a, * identical bits. Note that low bit numbers are assigned to high positions * in the byte, as we compare them as strings. */ - return (beg << 3) - flsnz_long(c); + return (beg << 3) - flsnz(c); } static forceinline int cmp_bits(const unsigned char *a, const unsigned char *b, unsigned int pos)