perf: flat tickers

This commit is contained in:
cha0s 2019-05-05 20:04:50 -05:00
parent 4d18430260
commit 4bece84a47

View File

@ -16,7 +16,7 @@ export function Synchronized(Superclass) {
this.state = I.Map();
this._childrenWithState = []
this._childrenWithoutState = [];
this._childrenWithTickers = [];
this._childrenTickers = [];
}
initializeSynchronizedChildren() {
@ -27,7 +27,7 @@ export function Synchronized(Superclass) {
'undefined' !== typeof this[key]
&& 'undefined' !== typeof this[key].tick
) {
this._childrenWithTickers.push(key);
this._childrenTickers.push(this[key].tick.bind(this[key]));
}
if (
'undefined' !== typeof this[key]
@ -84,9 +84,8 @@ export function Synchronized(Superclass) {
}
tick(elapsed) {
for (let i = 0; i < this._childrenWithTickers.length; ++i) {
const key = this._childrenWithTickers[i];
this[key].tick(elapsed);
for (let i = 0; i < this._childrenTickers.length; ++i) {
this._childrenTickers[i](elapsed);
}
if (AVOCADO_SERVER) {
this.tickMutateState();