clean up objectHasDiff and short circuit it quicker
This commit is contained in:
parent
49f511bbab
commit
02ae1e954b
1 changed files with 2 additions and 3 deletions
|
@ -89,10 +89,9 @@ export function objectHasDiff<O extends {}>(a: O, b: O): boolean {
|
||||||
if (a === b) return false;
|
if (a === b) return false;
|
||||||
const aKeys = Object.keys(a);
|
const aKeys = Object.keys(a);
|
||||||
const bKeys = Object.keys(b);
|
const bKeys = Object.keys(b);
|
||||||
const possibleChanges = arrayUnion(aKeys, bKeys);
|
if (aKeys.length !== bKeys.length) return true;
|
||||||
// if the amalgamation of both sets of keys has the a different length to the inputs then there must be a change
|
|
||||||
if (possibleChanges.length !== aKeys.length) return true;
|
|
||||||
|
|
||||||
|
const possibleChanges = arrayUnion(aKeys, bKeys);
|
||||||
return possibleChanges.some(k => a[k] !== b[k]);
|
return possibleChanges.some(k => a[k] !== b[k]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue