From c61ae8de9e1147a1540d3f063cffe7e30bc977a0 Mon Sep 17 00:00:00 2001 From: melloware Date: Fri, 18 Aug 2023 17:54:54 -0400 Subject: [PATCH] Fix #4797: ObjectUtils.resolveFieldData perf improvement --- components/lib/utils/ObjectUtils.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/components/lib/utils/ObjectUtils.js b/components/lib/utils/ObjectUtils.js index fefccaa5fa..3454515fac 100644 --- a/components/lib/utils/ObjectUtils.js +++ b/components/lib/utils/ObjectUtils.js @@ -57,6 +57,11 @@ export default class ObjectUtils { } static resolveFieldData(data, field) { + if (!data || !field) { + // short circuit if there is nothing to resolve + return null; + } + try { const value = data[field]; @@ -66,7 +71,7 @@ export default class ObjectUtils { // do nothing and continue to other methods to resolve field data } - if (data && Object.keys(data).length && field) { + if (Object.keys(data).length) { if (this.isFunction(field)) { return field(data); } else if (ObjectUtils.isNotEmpty(data[field])) { @@ -87,9 +92,9 @@ export default class ObjectUtils { return value; } - } else { - return null; } + + return null; } static findDiffKeys(obj1, obj2) {