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
+2 -2
View File
@@ -101,7 +101,7 @@ export function getClosestHandle(
let closestHandles: { handle: ConnectionHandle; validHandleResult: ValidHandleResult }[] = []
let minDistance = Number.POSITIVE_INFINITY
handles.forEach((handle) => {
for (const handle of handles) {
const distance = Math.sqrt((handle.x - pos.x) ** 2 + (handle.y - pos.y) ** 2)
if (distance <= connectionRadius) {
@@ -121,7 +121,7 @@ export function getClosestHandle(
minDistance = distance
}
}
})
}
if (!closestHandles.length) {
return { handle: null, validHandleResult: defaultValidHandleResult() }