-
Notifications
You must be signed in to change notification settings - Fork 30k
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
querystring: improve querystring unescapeBuffer perf #12525
Conversation
Refactored the unescapeBuffer function in order to simplify it, and also to improve the performance. The benchmark: ```improvement confidence p.value querystring/querystring-unescapebuffer.js n=1000000 input="%20%21%2..." 18.10 % *** 6.671620e-29 querystring/querystring-unescapebuffer.js n=1000000 input="there%20..." 2.75 % * 1.775320e-02 querystring/querystring-unescapebuffer.js n=1000000 input="there%2Q..." 34.12 % *** 8.074612e-25 querystring/querystring-unescapebuffer.js n=1000000 input="there is..." 27.92 % *** 4.923348e-29 ```
lib/querystring.js
Outdated
} | ||
|
||
|
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.
Unnecessary whitespace change
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.
What is the standard? Because the file contains both 2 and 1 line separation between functions.
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.
My own opinion is that such changes should be addressed separately.
lib/querystring.js
Outdated
if (c === 37 /*'%'*/ && index < maxLength) { | ||
c = s.charCodeAt(++index); | ||
n = unhexTable[c]; | ||
if (n < 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.
This won't work for characters not in the table. This is why I had used !(n >= 0)
, which will cover undefined
as well.
lib/querystring.js
Outdated
} else { | ||
c1 = s.charCodeAt(++index); | ||
m = unhexTable[c1]; | ||
if (m < 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.
Ditto.
The subsystem target in the commit message should be |
@mscdex subsystem changed, also the three changes asked commited. |
lib/querystring.js
Outdated
if (c === 37 /*'%'*/ && index < maxLength) { | ||
c = s.charCodeAt(++index); | ||
n = unhexTable[c]; | ||
if !(n >= 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.
Missing parens. These sorts of things should be caught by make jslint
.
lib/querystring.js
Outdated
} else { | ||
c1 = s.charCodeAt(++index); | ||
m = unhexTable[c1]; | ||
if !(m >= 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.
Ditto.
@mscdex sorry, fixed, lint passing ok, also tests. |
lib/querystring.js
Outdated
break; | ||
var index = 0; | ||
var outIndex = 0; | ||
var c, c1, n, m; |
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.
Can we name these better and place them on separate lines?
My benchmark results seem to agree more or less with those already posted. |
Rename variables and separate in lines.
@mscdex Variables renamed and separated in lines. Lint passing. UT passing. Benchmark times remains similar. |
Hi @mscdex! Do you need more changes to be made, or you are ok with this? I see that not all the CI is passing :( |
SGTM. |
@jseijas It's fine if CI still checks out and there are no performance regressions. Can you please rebase against current master and re-run the benchmarks? I think V8 5.8 was added since this PR was opened and may/may not have an impact on this. |
@mscdex Of course I can :) I will come back with the results. |
@mscdex Done. Now is even better.
|
LGTM |
Landed in 19685ea. |
Refactored the `unescapeBuffer` function in order to simplify it, and also to improve the performance. PR-URL: #12525 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
Refactored the `unescapeBuffer` function in order to simplify it, and also to improve the performance. PR-URL: #12525 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
should this land in LTS? If so it will need to bake a bit longer. Please change labels as appropriate |
Refactored the unescapeBuffer function in order to simplify it,
and also to improve the performance.
The benchmark:
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)