Skip to content

Commit

Permalink
Add best case parser infront
Browse files Browse the repository at this point in the history
  • Loading branch information
uNetworkingAB committed Mar 9, 2024
1 parent ea226c4 commit 45091fa
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/HttpParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,27 @@ struct HttpParser {
}

static inline void *consumeFieldName(char *p) {
/* Best case fast path (particularly useful with clang) */
while (true) {
while ((*p >= 65) & (*p <= 90)) [[likely]] {
*p |= 32;
p++;
}
while (((*p >= 97) & (*p <= 122))) [[likely]] {
p++;
}
if (*p == ':') {
return (void *)p;
}
if (*p == '-') {
p++;
} else if (!((*p >= 65) & (*p <= 90))) {
/* Exit fast path parsing */
break;
}
}

/* Generic */
while (isFieldNameByteFastLowercased(*(unsigned char *)p)) {
p++;
}
Expand Down

0 comments on commit 45091fa

Please sign in to comment.