perf(core): replace Array.forEach loops

This commit is contained in:
braks
2024-02-05 07:51:12 +01:00
committed by Braks
parent 66d7198a2f
commit c4b4a04aa0
9 changed files with 57 additions and 42 deletions
+4 -4
View File
@@ -114,7 +114,7 @@ export function applyChanges<
| EdgeRemoveChange
)[]
addRemoveChanges.forEach((change) => {
for (const change of addRemoveChanges) {
if (change.type === 'add') {
const index = elements.findIndex((el) => el.id === change.item.id)
@@ -128,11 +128,11 @@ export function applyChanges<
elements.splice(index, 1)
}
}
})
}
const elementIds = elements.map((el) => el.id)
elements.forEach((element) => {
for (const element of elements) {
const currentChanges = changes.filter((c) => (<any>c).id === element.id)
for (const currentChange of currentChanges) {
@@ -198,7 +198,7 @@ export function applyChanges<
break
}
}
})
}
return elements
}