Skip to content

Best practice derived atom #612

Closed Answered by dai-shi
marcselman asked this question in Q&A
Discussion options

You must be logged in to vote

Technically, get comes with a few function calls, one Map lookup, one Set addition, and invalidation check whose cost depends (hard to estimate, and there might be room for optimization).
So, having the result in a local variable would be better.
But, it's not noticeable unless it's an extreme case.
We should care more about the code readability and maybe bundle size.

I would probably do the second example in your use case. The code tells it's reading only one atom. (In the first example, you would need to double check if all gets take the same atom.)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by marcselman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants