goatslacker / goatslacker/alt

Isn't fn.assign useless inside getState?

Open
#703 0 comments 5 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
3.4k
Forks
312
PR merge metrics
No merged PRs in 30d

Description

In my application I call getState so frequently that it even affects performance. I started to investigate and and came across `fn.assign` here:
```js
getState(state) {
if (Array.isArray(state)) {
return state.slice()
} else if (fn.isMutableObject(state)) {
return fn.assign({}, state)
}

return state
}
```

To my mind it's absolutely useless as it does only shallow copy which means inner mutable objects will still be mutable after assigning. Seems that this code just ... slows down performance?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.