prevent unnecessary re-rendering of rountangles and diamonds

This commit is contained in:
Joeri Exelmans 2025-10-23 21:47:39 +02:00
parent 0fc3775a11
commit 2ca2ba5d1b
5 changed files with 45 additions and 12 deletions

View file

@ -23,3 +23,18 @@ export function memoize<InType,OutType>(fn: (i: InType) => OutType) {
return result;
}
}
// compare arrays by value
export function arraysEqual<T>(a: T[], b: T[], cmp: (a: T, b: T) => boolean = (a,b)=>a===b): boolean {
if (a === b)
return true;
if (a.length !== b.length)
return false;
for (let i=0; i<a.length; i++)
if (!cmp(a[i],b[i]))
return false;
return true;
}