Skip to content

Commit e09202b

Browse files
bnoordhuisevanlucas
authored andcommittedMay 2, 2017
net: don't create unnecessary closure
Pass arguments to fireErrorCallbacks() explicitly. Saves allocation an unnecessary closure context. PR-URL: #12342 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 8e3d54a commit e09202b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎lib/net.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ Socket.prototype.destroySoon = function() {
476476
Socket.prototype._destroy = function(exception, cb) {
477477
debug('destroy');
478478

479-
function fireErrorCallbacks(self) {
479+
function fireErrorCallbacks(self, exception, cb) {
480480
if (cb) cb(exception);
481481
if (exception && !self._writableState.errorEmitted) {
482482
process.nextTick(emitErrorNT, self, exception);
@@ -486,7 +486,7 @@ Socket.prototype._destroy = function(exception, cb) {
486486

487487
if (this.destroyed) {
488488
debug('already destroyed, fire error callbacks');
489-
fireErrorCallbacks(this);
489+
fireErrorCallbacks(this, exception, cb);
490490
return;
491491
}
492492

@@ -518,7 +518,7 @@ Socket.prototype._destroy = function(exception, cb) {
518518
// to make it re-entrance safe in case Socket.prototype.destroy()
519519
// is called within callbacks
520520
this.destroyed = true;
521-
fireErrorCallbacks(this);
521+
fireErrorCallbacks(this, exception, cb);
522522

523523
if (this._server) {
524524
COUNTER_NET_SERVER_CONNECTION_CLOSE(this);

0 commit comments

Comments
 (0)
Please sign in to comment.