Skip to content

Commit

Permalink
Fix primefaces#4797: ObjectUtils.resolveFieldData perf improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Aug 18, 2023
1 parent 15b0368 commit c61ae8d
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 c61ae8d

Please sign in to comment.