MINOR: h1-htx: Use a correlation table to speed-up small chunks parsing
Instead of using hex2i() to convert an hexa digit to an integer in the
function parsing small chunks, we now use a table because it is faster.
diff --git a/src/h1_htx.c b/src/h1_htx.c
index adb96e1..ec240a3 100644
--- a/src/h1_htx.c
+++ b/src/h1_htx.c
@@ -451,6 +451,17 @@
return ret;
}
+static const char hextable[] = {
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1,
+ -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
+};
+
/* Generic function to parse the current HTTP chunk. It may be used to parsed
* any kind of chunks, including incomplete HTTP chunks or splitted chunks
* because the buffer wraps. This version tries to performed zero-copy on large
@@ -598,7 +609,7 @@
goto end_parsing;
/* Convert current character */
- c = hex2i(end[ridx]);
+ c = hextable[(unsigned char)end[ridx]];
/* not a hex digit anymore */
if (c < 0)