fix: more efficient and correct reactive set #11967
Merged
+57
−79
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I reverted #11946 because I don't think it's the right fix. We don't need to read all the sources in a set every time we iterate over the keys — that's very wasteful indeed. Nor, in fact, do we need to add a source for every
set.add(value)
.The only thing that actually needed to change AFAICT is that we need to increment the version and update the size inside
delete
whenever a value was deleted. Previously we were only doing that when a source already existed.This PR fixes that, and makes things generally a bit simpler and more efficient (no more redundant source creation in
add
)Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests and linting
pnpm test
and lint the project withpnpm lint