From e09202b78b5f91f619e184fdb3b21d9165bef469 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 11 Apr 2017 16:22:32 +0200 Subject: [PATCH] net: don't create unnecessary closure Pass arguments to fireErrorCallbacks() explicitly. Saves allocation an unnecessary closure context. PR-URL: https://github.com/nodejs/node/pull/12342 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Colin Ihrig Reviewed-By: Evan Lucas Reviewed-By: James M Snell Reviewed-By: Luigi Pinca --- lib/net.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/net.js b/lib/net.js index 40991aa6fb8a64..65d57b2b89545b 100644 --- a/lib/net.js +++ b/lib/net.js @@ -476,7 +476,7 @@ Socket.prototype.destroySoon = function() { Socket.prototype._destroy = function(exception, cb) { debug('destroy'); - function fireErrorCallbacks(self) { + function fireErrorCallbacks(self, exception, cb) { if (cb) cb(exception); if (exception && !self._writableState.errorEmitted) { process.nextTick(emitErrorNT, self, exception); @@ -486,7 +486,7 @@ Socket.prototype._destroy = function(exception, cb) { if (this.destroyed) { debug('already destroyed, fire error callbacks'); - fireErrorCallbacks(this); + fireErrorCallbacks(this, exception, cb); return; } @@ -518,7 +518,7 @@ Socket.prototype._destroy = function(exception, cb) { // to make it re-entrance safe in case Socket.prototype.destroy() // is called within callbacks this.destroyed = true; - fireErrorCallbacks(this); + fireErrorCallbacks(this, exception, cb); if (this._server) { COUNTER_NET_SERVER_CONNECTION_CLOSE(this);