-
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
dns: improve makeAsync internally by removing unneeded vaiable. #8800
Conversation
A few nits on the commit message:
I would suggest:
|
95e445d
to
5935ab5
Compare
The code that was changed looks like it may have been written that way as a performance optimization. /cc @mscdex |
@Trott do we have a benchmark for that you mean? The following is my bench file: function callback() {};
function testable() {
var args = new Array(arguments.length + 1);
args[0] = callback;
//for (var i = 0; i < arguments.length; i++)
// args[i + 1] = arguments[i];
for (var i = 1, a = 0; a < arguments.length; i++, a++)
args[i] = arguments[a];
return args;
}
var start = Date.now();
for (var i = 0; i < 100000000; i++) testable(1, 2, 3, 4, 5);
var end = Date.now();
console.log(end - start); Because Node.js doesn't expose this utility function, thus I have to rewrite once for this tests, correct me if I'm wrong, thanks :) |
LGTM |
Ok, CI is running: https://ci.nodejs.org/job/node-test-pull-request/4299/ |
LGTM |
@Trott Never mind, now this change LGTY? I hope a review from you :) |
5935ab5
to
f233d87
Compare
PR-URL: nodejs#8800 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
f233d87
to
7bc6aea
Compare
Landed in 7bc6aea, thanks :) |
PR-URL: #8800 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
PR-URL: #8800 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Checklist
make -j8 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
dns
Description of change
This removes the unneeded variable inside the MakeCallback's loop. And I have made a benchmark by myself, with 100,000,000 calls and 5 arguments per call, the optimized gets decreased about 500ms.