-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
potential optimization - bail out of executeSubSelectedArray
calls
#11670
Conversation
🦋 Changeset detectedLatest commit: aa388af The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
/release:pr |
size-limit report 📦
|
A new release has been made for this PR. You can install it with:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks safe to me. The StoreReader
often returns fieldValue
to application code without making a defensive copy, but frozen (in development), so copying fieldValue
in this case seems unusual/unnecessary.
src/cache/inmemory/readFromStore.ts
Outdated
fieldValue = | ||
fieldValue.length === 0 ? | ||
fieldValue | ||
: handleMissing( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could probably rearrange this so it only calls handleMissing
and updates fieldValue
if fieldValue.length > 0
, but I leave that 🏌️ up to you.
✅ Deploy Preview for apollo-client-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for apollo-client-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! 🎉
This just came up in #11669 and I wanted to try it out.
One thing to consider strongly here is that this returns the original empty array, so I'll have to investigate if that could make it out of the cache where users could accidentally start manipulating it (and if we see this as a problem).
We could have a "weak empty array mapping cache" somewhere to prevent that, but at that point I'm not sure if this optimization does make any sense at all.