From 27c90efce06061c62919ba20227902331c0c4ac3 Mon Sep 17 00:00:00 2001 From: fuxingZhang <502545703@qq.com> Date: Thu, 28 May 2020 11:01:12 +0800 Subject: [PATCH] events: variable originalListener is useless PR-URL: https://github.com/nodejs/node/pull/33596 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Yongsheng Zhang Reviewed-By: Colin Ihrig --- lib/events.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/events.js b/lib/events.js index fc2f969ea37ef6..a5af5ff9309c18 100644 --- a/lib/events.js +++ b/lib/events.js @@ -449,8 +449,6 @@ EventEmitter.prototype.prependOnceListener = // Emits a 'removeListener' event if and only if the listener was removed. EventEmitter.prototype.removeListener = function removeListener(type, listener) { - let originalListener; - checkListener(listener); const events = this._events; @@ -474,7 +472,6 @@ EventEmitter.prototype.removeListener = for (let i = list.length - 1; i >= 0; i--) { if (list[i] === listener || list[i].listener === listener) { - originalListener = list[i].listener; position = i; break; } @@ -495,7 +492,7 @@ EventEmitter.prototype.removeListener = events[type] = list[0]; if (events.removeListener !== undefined) - this.emit('removeListener', type, originalListener || listener); + this.emit('removeListener', type, listener); } return this;