-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix performance regression in node:http from #18599 #18798
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have test failures, we need to make sure that node:http remains compatible, otherwise I think that the chances are in the right direction
// This is the equivalent of checkIsHttpToken from internal/validators.js | ||
// The regex is /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/ | ||
for (const auto& c : name) { | ||
if (!(c == '^' || c == '_' || c == '`' || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '-' || (c >= '0' && c <= '9') || c == '!' || c == '#' || c == '$' || c == '%' || c == '&' || c == '\'' || c == '*' || c == '+' || c == '.' || c == '|' || c == '~')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this faster than a switch statement? because is not easy to read
@@ -41,6 +41,16 @@ bool isTokenCharacter(UChar c) | |||
|| c == '`' || c == '|' || c == '~'; | |||
} | |||
|
|||
bool isTokenCharacter(LChar c) | |||
{ | |||
return isASCIIAlpha(c) || isASCIIDigit(c) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just like how this is formatted in a way that is easier to read than a switch/case
if (hasBody) { | ||
// Don't automatically read the body, the user will need to resume() or .on("data") to read it. | ||
// But, avoid the system call overhead unless we are going to receive body data. | ||
handle.pause(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should have added this check from the start, thanks
What does this PR do?
Fix performance regression in node:http from #18599
How did you verify your code works?