Skip to content

Commit

Permalink
Don't mess up underscore, make it 14% faster
Browse files Browse the repository at this point in the history
  • Loading branch information
uNetworkingAB committed Mar 9, 2024
1 parent da62fb6 commit 92ebd48
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion libEpollBenchmarker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ override CFLAGS += -DUWS_NO_ZLIB -I../src -I../uSockets/src

default:
make -C ../uSockets
g++ -flto -O3 -std=c++17 ../examples/HelloWorld.cpp epoll_benchmarker.cpp $(CFLAGS) -o HelloWorld ../uSockets/uSockets.a
$(CXX) -flto -O3 -std=c++17 ../examples/HelloWorld.cpp epoll_benchmarker.cpp $(CFLAGS) -o HelloWorld ../uSockets/uSockets.a
28 changes: 16 additions & 12 deletions src/HttpParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,20 +247,24 @@ struct HttpParser {
hasBetween(x, 'Z', 'a') |
hasMore(x, 'z');
}

static inline bool isFieldNameByteFastLowercased(unsigned char &in) {
if ((in >= 97 & in <= 122) | (in == '-')) [[likely]] {
return true;
} else if (in >= 65 & in <= 90) [[unlikely]] {
in |= 32;
return true;
} else if (isFieldNameByte(in)) [[unlikely]] {
return true;
}
return false;
}

static inline void *consumeFieldName(char *p) {
//for (; true; p += 8) {
//uint64_t word;
//memcpy(&word, p, sizeof(uint64_t));
//if (notFieldNameWord(word)) {
while (isFieldNameByte(*(unsigned char *)p)) {
*(p++) |= 0x20;
}
return (void *)p;
//}
//word |= 0x2020202020202020ull;
//memcpy(p, &word, sizeof(uint64_t));
//}
while (isFieldNameByteFastLowercased(*(unsigned char *)p)) {
p++;
}
return (void *)p;
}

/* Puts method as key, target as value and returns non-null (or nullptr on error). */
Expand Down

0 comments on commit 92ebd48

Please sign in to comment.