perf: less memory churn
This commit is contained in:
parent
030bf436c4
commit
4378ef2a12
|
@ -41,25 +41,19 @@ function tick(now) {
|
||||||
ecs.tick(elapsed);
|
ecs.tick(elapsed);
|
||||||
emitter.tick(elapsed);
|
emitter.tick(elapsed);
|
||||||
const update = {};
|
const update = {};
|
||||||
const lastNearby = new Set(memory);
|
for (const id in ecs.diff) {
|
||||||
for (const id in ecs.$$entities) {
|
if (false === ecs.diff[id]) {
|
||||||
const entity = ecs.$$entities[id];
|
memory.delete(id);
|
||||||
if (ecs.$$detached.has(entity.id)) {
|
update[id] = false;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
lastNearby.delete(id);
|
else if (!memory.has(id)) {
|
||||||
if (!memory.has(id)) {
|
update[id] = ecs.$$entities[id].toJSON();
|
||||||
update[id] = entity.toJSON();
|
|
||||||
}
|
}
|
||||||
else if (ecs.diff[id]) {
|
else if (ecs.diff[id]) {
|
||||||
update[id] = ecs.diff[id];
|
update[id] = ecs.diff[id];
|
||||||
}
|
}
|
||||||
memory.add(id);
|
memory.add(id);
|
||||||
}
|
}
|
||||||
for (const id of lastNearby) {
|
|
||||||
memory.delete(id);
|
|
||||||
update[id] = false;
|
|
||||||
}
|
|
||||||
if ('1' in update) {
|
if ('1' in update) {
|
||||||
delete update['1'];
|
delete update['1'];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user