perf: skip state mutation if possible

This commit is contained in:
cha0s 2019-05-08 21:17:00 -05:00
parent 7731dca9e7
commit 14a252db3a
2 changed files with 6 additions and 0 deletions

View File

@ -339,6 +339,9 @@ export class Entity extends decorate(Resource) {
}
tickMutateState() {
if (0 === this._traitsTypesDirty.length) {
return;
}
this.state = this.state.withMutations((state) => {
for (let i = 0; i < this._traitsTypesDirty.length; i++) {
const type = this._traitsTypesDirty[i];

View File

@ -148,6 +148,9 @@ export class EntityList extends decorate(class {}) {
}
tickMutateState(state) {
if (0 === this._dirtyEntities.length) {
return;
}
this.state = this.state.withMutations((state) => {
for (let i = 0; i < this._dirtyEntities.length; i++) {
const entity = this._dirtyEntities[i];