perf(runtime-vapor): implement dynamic props/slots source caching#14208
perf(runtime-vapor): implement dynamic props/slots source caching#14208edison1105 merged 5 commits intominorfrom
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 You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/compiler-vapor
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/runtime-vapor
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
There was a problem hiding this comment.
Pull request overview
This PR implements a performance optimization by adding caching for dynamic props and slots sources. Previously, when a component accessed multiple props from the same v-bind source (e.g., v-bind="obj"), the source function was called multiple times. Now it's cached using a computed ref, so the source is only evaluated once per reactive update cycle.
Key changes:
- Created a generic
resolveDynamicFunctionSourceutility that caches function results using computed refs - Consolidated caching logic from
componentSlots.tsintocomponentProps.tsfor reuse - Updated all dynamic source resolution sites to use the new caching function
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
packages/runtime-vapor/src/componentSlots.ts |
Removed local resolveDynamicSlot function and updated to use the shared resolveDynamicFunctionSource from componentProps |
packages/runtime-vapor/src/componentProps.ts |
Added resolveDynamicFunctionSource with computed-based caching and scope disposal, updated all dynamic source resolution call sites to use it |
packages/runtime-vapor/__tests__/componentProps.spec.ts |
Added comprehensive tests validating that v-bind sources are cached when multiple props are accessed and that reactivity still works correctly |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.