From 355041960d9b495e10f53389f0ea497dc611016c Mon Sep 17 00:00:00 2001 From: cjihrig Date: Thu, 27 Oct 2016 17:37:40 -0400 Subject: [PATCH] events: remove unnecessary checks This commit removes two truthy checks for object properties that are immediately followed by a strict equality check. The other item in the comparison is guaranteed to be a function by this point in the code, so the truthy check is redundant. PR-URL: https://github.com/nodejs/node/pull/9330 Reviewed-By: Rich Trott Reviewed-By: James M Snell Reviewed-By: Anna Henningsen --- lib/events.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/events.js b/lib/events.js index da2dc599cacc32..e7202bfedd0c55 100644 --- a/lib/events.js +++ b/lib/events.js @@ -327,7 +327,7 @@ EventEmitter.prototype.removeListener = if (!list) return this; - if (list === listener || (list.listener && list.listener === listener)) { + if (list === listener || list.listener === listener) { if (--this._eventsCount === 0) this._events = new EventHandlers(); else { @@ -339,8 +339,7 @@ EventEmitter.prototype.removeListener = position = -1; for (i = list.length; i-- > 0;) { - if (list[i] === listener || - (list[i].listener && list[i].listener === listener)) { + if (list[i] === listener || list[i].listener === listener) { originalListener = list[i].listener; position = i; break;