From 02ae1e954b06b82122984e63100f980280e483c6 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 19 Feb 2021 11:40:34 +0000 Subject: [PATCH] clean up objectHasDiff and short circuit it quicker --- src/utils/objects.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/utils/objects.ts b/src/utils/objects.ts index 166c31c4c3..f240fe2f7d 100644 --- a/src/utils/objects.ts +++ b/src/utils/objects.ts @@ -89,10 +89,9 @@ export function objectHasDiff(a: O, b: O): boolean { if (a === b) return false; const aKeys = Object.keys(a); const bKeys = Object.keys(b); - const possibleChanges = arrayUnion(aKeys, bKeys); - // 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; + if (aKeys.length !== bKeys.length) return true; + const possibleChanges = arrayUnion(aKeys, bKeys); return possibleChanges.some(k => a[k] !== b[k]); }