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()
|
- ✔ 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()
|
||||||
|
|
|
@ -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;
|
|
||||||
}, []);
|
}, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user