perf: cool off EventEmitters

This commit is contained in:
cha0s 2019-04-17 00:05:12 -05:00
parent 0952ffbd0e
commit d919af7812
2 changed files with 5 additions and 7 deletions

View File

@ -12,7 +12,7 @@
- ✔ Eliminate immutable.toJS() - ✔ Eliminate immutable.toJS()
- ✔ Track dirty entity state (entityList.tick()) - ✔ Track dirty entity state (entityList.tick())
- ✔ Investigate visibleEntities path - ✔ Investigate visibleEntities path
- Investigate lookupEmitListeners path - Investigate lookupEmitListeners path
- ❌ Investigate visibleBoundingBoxes path - ❌ Investigate visibleBoundingBoxes path
- EventEmitter::emit is too hot - EventEmitter::emit is too hot
- ❌ entityList.fromJSON() - ❌ entityList.fromJSON()

View File

@ -25,7 +25,8 @@ export function EventEmitterMixin(Superclass) {
return; return;
} }
for (const {once, type, namespace, fn, bound, that} of listeners) { for (let i = 0; i < listeners.length; ++i) {
const {once, type, namespace, fn, bound, that} = listeners[i];
const offset = type !== '*' ? 1 : 0; const offset = type !== '*' ? 1 : 0;
if (once) { if (once) {
@ -86,10 +87,7 @@ export function EventEmitterMixin(Superclass) {
lookupEmitListeners(type) { lookupEmitListeners(type) {
return ['*', type].reduce((r, type) => { return ['*', type].reduce((r, type) => {
if (type in this.$$events) { return r.concat(type in this.$$events ? this.$$events[type] : []);
r.push(...this.$$events[type]);
}
return r;
}, []); }, []);
} }