perf: cool off EventEmitters
This commit is contained in:
parent
0952ffbd0e
commit
d919af7812
4
TODO.md
4
TODO.md
|
@ -12,7 +12,7 @@
|
|||
- ✔ Eliminate immutable.toJS()
|
||||
- ✔ Track dirty entity state (entityList.tick())
|
||||
- ✔ Investigate visibleEntities path
|
||||
- ❌ Investigate lookupEmitListeners path
|
||||
- ✔ Investigate lookupEmitListeners path
|
||||
- ❌ Investigate visibleBoundingBoxes path
|
||||
- ❌ EventEmitter::emit is too hot
|
||||
- ✔ EventEmitter::emit is too hot
|
||||
- ❌ entityList.fromJSON()
|
||||
|
|
|
@ -25,7 +25,8 @@ export function EventEmitterMixin(Superclass) {
|
|||
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;
|
||||
|
||||
if (once) {
|
||||
|
@ -86,10 +87,7 @@ export function EventEmitterMixin(Superclass) {
|
|||
|
||||
lookupEmitListeners(type) {
|
||||
return ['*', type].reduce((r, type) => {
|
||||
if (type in this.$$events) {
|
||||
r.push(...this.$$events[type]);
|
||||
}
|
||||
return r;
|
||||
return r.concat(type in this.$$events ? this.$$events[type] : []);
|
||||
}, []);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user