Skip to content

Commit

Permalink
Optimize Emitter._installEvents()
Browse files Browse the repository at this point in the history
Check for #_eventTypes first, no need to do anything if they don't exist.
  • Loading branch information
lehni committed Feb 3, 2016
1 parent 922a502 commit 0f084ea
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/core/Emitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,18 @@ var Emitter = {
fire: '#emit',

_installEvents: function(install) {
var handlers = this._callbacks,
var types = this._eventTypes,
handlers = this._callbacks,
key = install ? 'install' : 'uninstall';
for (var type in handlers) {
if (handlers[type].length > 0) {
var types = this._eventTypes,
entry = types && types[type],
func = entry && entry[key];
if (func)
func.call(this, type);
}
if (types) {
for (var type in handlers) {
if (handlers[type].length > 0) {
var entry = types[type],
func = entry && entry[key];
if (func)
func.call(this, type);
}
}
}
},

Expand Down

0 comments on commit 0f084ea

Please sign in to comment.