-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
url: performance improvement in URL implementation #10469
Conversation
It looks like the file mode was changed accidentally. |
I've added |
grr.. ok, file mode should be fixed now. |
host, port, path, query, fragment) { | ||
if (flags & binding.URL_FLAGS_FAILED) | ||
return; | ||
const newIsSpecial = (flags & binding.URL_FLAGS_SPECIAL) != 0; |
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.
!==
?
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.
While you're at it, maybe !=
-> !==
on lines 222 and 226 below?
const s = this[special]; | ||
const ctx = this[context]; | ||
if ((s && !newIsSpecial) || | ||
(!s && newIsSpecial) || |
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.
Would !!s !== !!newIsSpecial
be better?
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.
how about !s !== !newIsSpecial
?
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.
this[special] is guaranteed to be a boolean. s
and !s
are sufficient. There's no need (and no benefit) for getting fancy with it.
Updated to address nits |
if ((s && !newIsSpecial) || | ||
(!s && newIsSpecial) || | ||
(newIsSpecial && !s && | ||
ctx.host === undefined)) { |
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.
3rd one will never trigger?
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.
ha! good catch... fixed!
host, port, path, query, fragment) { | ||
if (flags & binding.URL_FLAGS_FAILED) | ||
throw new TypeError('Invalid URL'); | ||
const ctx = this[context]; |
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'm surprised that we have to do this. Isn't it like caching the length of an array before a for
loop (which V8 is able to optimize)?
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 wouldn't say that we have to do this. This is more a code hygiene thing for me to avoid duplicated accessor calls but beyond that the impact is negligible.
This PR will need to be updated after #10408 lands. Marking as blocked until that does. |
Yields about a 25% average performance improvement
Updated.. unblocking |
Failures in freebsd are unrelated |
Yields about a 25% average performance improvement PR-URL: #10469 Reviewed-By: Michaël Zasso <targos@protonmail.com>
Landed in 2213f36 |
FWIW I just noticed the file mode changed again in the landed commit. |
Ugh. My git client appears to be completely ignoring my global config
setting to ignore file mode changes. Getting quite frustrated with it.
Thanks for the heads up
…On Fri, Dec 30, 2016 at 12:55 PM Brian White ***@***.***> wrote:
FWIW I just noticed the file mode changed again in the landed commit.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#10469 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAa2ecyLIEsShUdeZDZEqL7tm0v8ZGqXks5rNW_CgaJpZM4LWB-R>
.
|
Yields about a 25% average performance improvement PR-URL: #10469 Reviewed-By: Michaël Zasso <targos@protonmail.com>
Yields about a 25% average performance improvement PR-URL: #10469 Reviewed-By: Michaël Zasso <targos@protonmail.com>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
url
Description of change
Yields about a 25% average performance improvement