Skip to content

Commit

Permalink
events: remove unreachable code
Browse files Browse the repository at this point in the history
Commit 8d386ed stopped the
Event Emitter implementation from storing arrays containing a
single listener. This change left a section of code in
removeListener() as unreachable. This commit removes the
unreachable code.

Refs: #12043
PR-URL: #12501
Backport-PR-URL: #13796
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
cjihrig authored and gibfahn committed Jun 20, 2017
1 parent ab9dfbf commit fd3f89a
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,22 +349,13 @@ EventEmitter.prototype.removeListener =
if (position < 0)
return this;

if (list.length === 1) {
if (--this._eventsCount === 0) {
this._events = new EventHandlers();
return this;
} else {
delete events[type];
}
} else if (position === 0) {
if (position === 0)
list.shift();
if (list.length === 1)
events[type] = list[0];
} else {
else
spliceOne(list, position);
if (list.length === 1)
events[type] = list[0];
}

if (list.length === 1)
events[type] = list[0];

if (events.removeListener)
this.emit('removeListener', type, originalListener || listener);
Expand Down

0 comments on commit fd3f89a

Please sign in to comment.