Skip to content

Commit

Permalink
Fix #4797: ObjectUtils.resolveFieldData perf improvement (#4800)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Aug 19, 2023
1 parent 543a15f commit 48723c1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions components/lib/utils/ObjectUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand All @@ -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])) {
Expand All @@ -87,9 +92,9 @@ export default class ObjectUtils {

return value;
}
} else {
return null;
}

return null;
}

static findDiffKeys(obj1, obj2) {
Expand Down

0 comments on commit 48723c1

Please sign in to comment.