Skip to content

Commit 3550419

Browse files
cjihrigevanlucas
authored andcommitted
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: #9330 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 31690a6 commit 3550419

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/events.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ EventEmitter.prototype.removeListener =
327327
if (!list)
328328
return this;
329329

330-
if (list === listener || (list.listener && list.listener === listener)) {
330+
if (list === listener || list.listener === listener) {
331331
if (--this._eventsCount === 0)
332332
this._events = new EventHandlers();
333333
else {
@@ -339,8 +339,7 @@ EventEmitter.prototype.removeListener =
339339
position = -1;
340340

341341
for (i = list.length; i-- > 0;) {
342-
if (list[i] === listener ||
343-
(list[i].listener && list[i].listener === listener)) {
342+
if (list[i] === listener || list[i].listener === listener) {
344343
originalListener = list[i].listener;
345344
position = i;
346345
break;

0 commit comments

Comments
 (0)