perf(form-core): extract meta markers to state object (v2) - #2269
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
In order to compute if we can re-use the previous meta, we currently tag
two properties onto the meta (`derivedMetaSourceKey`,
`derivedMetaCanDisplayErrorsKey`).
This is fairly expensive because it means we change the shape of an
otherwise consistently structured object each time the value changes.
We only make use of this when the value changes, so this change switches
to using a `markers` object which transitions between values.
Basically this pattern:
```ts
const markers = { ... };
createAtom((prev) => {
// in here, mutate `markers` when prev != curr
});
```
This means the underlying meta object never changes shape.
Also important to note, this now means `getFieldSnapshot` doesn't even
pass through this code path anymore.
NOTE: there's also a bit of a drive-by in here. I updated
`nameToFieldNodeSegments` to slice between separators instead of
appending characters one-by-one. Much faster, but can be split into its
own PR if needed.
|
View your CI Pipeline Execution ↗ for commit 9f4521a
☁️ Nx Cloud last updated this comment at |
More templates
@tanstack/angular-form
@tanstack/form-core
@tanstack/form-devtools
@tanstack/lit-form
@tanstack/preact-form
@tanstack/react-form
@tanstack/react-form-devtools
@tanstack/react-form-nextjs
@tanstack/react-form-start
@tanstack/solid-form
@tanstack/solid-form-devtools
@tanstack/svelte-form
@tanstack/vue-form
commit: |
|
Thanks! |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## alpha #2269 +/- ##
========================================
Coverage ? 96.06%
========================================
Files ? 28
Lines ? 2669
Branches ? 743
========================================
Hits ? 2564
Misses ? 99
Partials ? 6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
In order to compute if we can re-use the previous meta, we currently tag
two properties onto the meta (
derivedMetaSourceKey,derivedMetaCanDisplayErrorsKey).This is fairly expensive because it means we change the shape of an
otherwise consistently structured object each time the value changes.
We only make use of this when the value changes, so this change switches
to using a
markersobject which transitions between values.Basically this pattern:
This means the underlying meta object never changes shape.
Also important to note, this now means
getFieldSnapshotdoesn't evenpass through this code path anymore.
NOTE: there's also a bit of a drive-by in here. I updated
nameToFieldNodeSegmentsto slice between separators instead ofappending characters one-by-one. Much faster, but can be split into its
own PR if needed.
✅ Checklist
pnpm test:pr.🚀 Release Impact