Skip to content

Commit

Permalink
events: optimize various functions
Browse files Browse the repository at this point in the history
Cache events and listeners objects where possible and loop over
Object.keys() instead of using for..in. These changes alone give
~60-65% improvement in the ee-add-remove benchmark.

The changes to EventEmitter.listenerCount() gives ~14%
improvement and changes to emitter.listeners() gives
significant improvements for <50 listeners
(~195% improvement for 10 listeners).

The changes to emitter.emit() gives 3x speedup for the fast
cases with multiple handlers and a minor speedup for the slow
case with multiple handlers.

The swapping out of the util.is* type checking functions with inline
checks gives another ~5-10% improvement.
  • Loading branch information
mscdex committed Feb 5, 2015
1 parent 10277d2 commit bf8d55c
Show file tree
Hide file tree
Showing 2 changed files with 192 additions and 98 deletions.
Loading

0 comments on commit bf8d55c

Please sign in to comment.