Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
  • Loading branch information
cjihrig committed Oct 31, 2016
commit 7f909c3b7922a3c7cdca03527dd6dc3687ae4e8b
5 changes: 2 additions & 3 deletions lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
Expand Down