Commit 8d386ed7 authored by Luigi Pinca's avatar Luigi Pinca Committed by James M Snell
Browse files

events: do not keep arrays with a single listener

Use the remaining listener directly if the array of listeners has only
one element after running `EventEmitter.prototype.removeListener()`.

Advantages:

- Better memory usage and better performance if no new listeners are
  added for the same event.

Disadvantages:

- A new array must be created if new listeners are added for the same
  event.

PR-URL: https://github.com/nodejs/node/pull/12043


Reviewed-By: default avatarJames M Snell <jasnell@gmail.com>
Reviewed-By: default avatarMatteo Collina <matteo.collina@gmail.com>
Reviewed-By: default avatarDaijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: default avatarRon Korving <ron@ronkorving.nl>
parent f637703b
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment