]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: tools: don't use unlikely() in hex2i()
authorWilly Tarreau <w@1wt.eu>
Fri, 10 Nov 2017 10:19:54 +0000 (11:19 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 10 Nov 2017 10:19:54 +0000 (11:19 +0100)
This small inline function causes some pain to the compiler when used
inside other functions due to its use of the unlikely() hint for non-digits.
It causes the letters to be processed far away in the calling function and
makes the code less efficient. Removing these unlikely() hints has increased
the chunk size parsing by around 5%.

include/common/standard.h

index a06fb84461f5154cd7fd59ba767bdac4b66fba3f..d88599de44cc10cbf340acaadbfa4a9864b21785 100644 (file)
@@ -317,9 +317,9 @@ extern int ishex(char s);
  */
 static inline int hex2i(int c)
 {
-       if (unlikely((unsigned char)(c -= '0') > 9)) {
-               if (likely((unsigned char)(c -= 'A' - '0') > 5 &&
-                             (unsigned char)(c -= 'a' - 'A') > 5))
+       if ((unsigned char)(c -= '0') > 9) {
+               if ((unsigned char)(c -= 'A' - '0') > 5 &&
+                             (unsigned char)(c -= 'a' - 'A') > 5)
                        c = -11;
                c += 10;
        }