perf: avoid work

This commit is contained in:
cha0s 2024-07-02 20:57:35 -05:00
parent 26b85f6520
commit e2cad034c2

View File

@ -62,10 +62,18 @@ export default class Ecs {
creating.push([entityId, componentsToUpdate]);
}
}
this.destroyMany(destroying);
await this.insertMany(updating);
this.removeMany(removing);
await this.createManySpecific(creating);
if (destroying.length > 0) {
this.destroyMany(destroying);
}
if (updating.length > 0) {
await this.insertMany(updating);
}
if (removing.length > 0) {
this.removeMany(removing);
}
if (creating.length > 0) {
await this.createManySpecific(creating);
}
}
changed(criteria) {
@ -111,6 +119,9 @@ export default class Ecs {
}
async createManySpecific(specificsList) {
if (0 === specificsList.length) {
return;
}
const entityIds = [];
const creating = {};
for (let i = 0; i < specificsList.length; i++) {