Skip to content

Commit

Permalink
Eliminate redundant object creation in resolveFunctionKeys
Browse files Browse the repository at this point in the history
Building an object of N keys incrementally using Object.reduce + splat results in N intermediate objects. We should just create one object and assign each key.
  • Loading branch information
thecrypticace committed May 23, 2022
1 parent a06d29e commit 6c1d3a4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/util/resolveConfig.js
Expand Up @@ -206,10 +206,9 @@ function resolveFunctionKeys(object) {
})

return Object.keys(object).reduce((resolved, key) => {
return {
...resolved,
[key]: isFunction(object[key]) ? object[key](resolvePath, configUtils) : object[key],
}
resolved[key] = isFunction(object[key]) ? object[key](resolvePath, configUtils) : object[key]

return resolved
}, {})
}

Expand Down

0 comments on commit 6c1d3a4

Please sign in to comment.