Performance update for resolveFieldData (#4290)

Object.keys can get expensive when called a lot of times. Adding a try catch for the quickest and probably highest use case can lead to big performance gains
pull/4142/head
MoMack20 2023-09-04 22:08:36 -04:00 committed by GitHub
parent 4a7d7e8a64
commit 7f5657bcbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -56,6 +56,15 @@ export default {
},
resolveFieldData(data, field) {
try {
const value = data[field];
if (value)
return value;
}
catch {
// do nothing and continue to other methods to resolve field data
}
if (data && Object.keys(data).length && field) {
if (this.isFunction(field)) {
return field(data);