Skip to content

Commit

Permalink
net: remove unnecessary variables
Browse files Browse the repository at this point in the history
V8 is smart enough to optimize the length property checking when
iterating over an array with a for loop.

PR-URL: #8112
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
mscdex authored and evanlucas committed Aug 24, 2016
1 parent d9142b4 commit 17b8381
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ exports.createServer = function(options, connectionListener) {
// connect(path, [cb]);
//
exports.connect = exports.createConnection = function() {
const argsLen = arguments.length;
var args = new Array(argsLen);
for (var i = 0; i < argsLen; i++)
var args = new Array(arguments.length);
for (var i = 0; i < arguments.length; i++)
args[i] = arguments[i];
args = normalizeConnectArgs(args);
debug('createConnection', args);
Expand Down Expand Up @@ -885,9 +884,8 @@ Socket.prototype.connect = function(options, cb) {
// Old API:
// connect(port, [host], [cb])
// connect(path, [cb]);
const argsLen = arguments.length;
var args = new Array(argsLen);
for (var i = 0; i < argsLen; i++)
var args = new Array(arguments.length);
for (var i = 0; i < arguments.length; i++)
args[i] = arguments[i];
args = normalizeConnectArgs(args);
return Socket.prototype.connect.apply(this, args);
Expand Down

0 comments on commit 17b8381

Please sign in to comment.