Skip to content

Commit

Permalink
events: remove unnecessary checks
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
cjihrig authored and MylesBorins committed Dec 21, 2016
1 parent 912cae6 commit 2ce6916
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,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 {
Expand All @@ -338,8 +338,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;
Expand Down

0 comments on commit 2ce6916

Please sign in to comment.