Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
events: optimize eventEmitter.once()
This basically removes the extra closure previously created by once() and instead uses an object to denote a one-time handler. The result is ~340% performance increase when adding one-time handlers, ~48% performance increase when emitting events with mixed persistent and one-time handlers, and ~10% performance increase when emitting with multiple arguments with mixed handlers, all with negligible negative performance impact to other EventEmitter functionality. Also, removeListener() was optimized a bit by eliminating handler arrays of length 1 so that the leftover handler is set on _events[type].
- Loading branch information