mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Optimize Emitter._installEvents()
Check for #_eventTypes first, no need to do anything if they don't exist.
This commit is contained in:
parent
922a502ee2
commit
0f084eaf02
1 changed files with 11 additions and 9 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue