perf: flatten pfu

This commit is contained in:
cha0s 2019-05-14 03:42:26 -05:00
parent 29abc9f540
commit f3273648b6

View File

@ -6,6 +6,9 @@ export class Synchronizer {
constructor(children) {
this.children = children;
this.childrenPacketsForUpdate = this.children.map((child) => {
return child.packetsForUpdate.bind(child);
});
}
acceptPacket(packet) {
@ -16,8 +19,8 @@ export class Synchronizer {
packetsForUpdate(force = false) {
const packetsForUpdate = [];
for (let i = 0; i < this.children.length; i++) {
const childPacketsForUpdate = this.children[i].packetsForUpdate(force);
for (let i = 0; i < this.childrenPacketsForUpdate.length; i++) {
const childPacketsForUpdate = this.childrenPacketsForUpdate[i](force);
for (let j = 0; j < childPacketsForUpdate.length; j++) {
packetsForUpdate.push(childPacketsForUpdate[j]);
}