Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
dgram: fix possibly deoptimizing use of arguments
  • Loading branch information
vsemozhetbyt committed Feb 14, 2017
commit fcde94d8b4e2d04754501e356c30dd3b789dcf09
6 changes: 3 additions & 3 deletions lib/dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function replaceHandle(self, newHandle) {
self._handle = newHandle;
}

Socket.prototype.bind = function(port_ /*, address, callback*/) {
Socket.prototype.bind = function(port_, address_ /*, callback*/) {
let port = port_;

this._healthCheck();
Expand All @@ -141,7 +141,7 @@ Socket.prototype.bind = function(port_ /*, address, callback*/) {

this._bindState = BIND_STATE_BINDING;

if (typeof arguments[arguments.length - 1] === 'function')
if (arguments.length && typeof arguments[arguments.length - 1] === 'function')
this.once('listening', arguments[arguments.length - 1]);

if (port instanceof UDP) {
Expand All @@ -158,7 +158,7 @@ Socket.prototype.bind = function(port_ /*, address, callback*/) {
exclusive = !!port.exclusive;
port = port.port;
} else {
address = typeof arguments[1] === 'function' ? '' : arguments[1];
address = typeof address_ === 'function' ? '' : address_;
exclusive = false;
}

Expand Down