Skip to content

Commit 45091fa

Browse files
committed
Add best case parser infront
1 parent ea226c4 commit 45091fa

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/HttpParser.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,27 @@ struct HttpParser {
262262
}
263263

264264
static inline void *consumeFieldName(char *p) {
265+
/* Best case fast path (particularly useful with clang) */
266+
while (true) {
267+
while ((*p >= 65) & (*p <= 90)) [[likely]] {
268+
*p |= 32;
269+
p++;
270+
}
271+
while (((*p >= 97) & (*p <= 122))) [[likely]] {
272+
p++;
273+
}
274+
if (*p == ':') {
275+
return (void *)p;
276+
}
277+
if (*p == '-') {
278+
p++;
279+
} else if (!((*p >= 65) & (*p <= 90))) {
280+
/* Exit fast path parsing */
281+
break;
282+
}
283+
}
284+
285+
/* Generic */
265286
while (isFieldNameByteFastLowercased(*(unsigned char *)p)) {
266287
p++;
267288
}

0 commit comments

Comments
 (0)