refactor(runtime-core): refactor props resolution

Improve performance in optimized mode + tests
This commit is contained in:
Evan You
2020-04-06 17:37:47 -04:00
parent c28a9196b2
commit ec4a4c1e06
14 changed files with 440 additions and 196 deletions

View File

@@ -42,7 +42,7 @@ import {
invalidateJob
} from './scheduler'
import { effect, stop, ReactiveEffectOptions, isRef } from '@vue/reactivity'
import { resolveProps } from './componentProps'
import { updateProps } from './componentProps'
import { resolveSlots } from './componentSlots'
import { pushWarningContext, popWarningContext, warn } from './warning'
import { ComponentPublicInstance } from './componentProxy'
@@ -226,7 +226,8 @@ export type MountComponentFn = (
anchor: RendererNode | null,
parentComponent: ComponentInternalInstance | null,
parentSuspense: SuspenseBoundary | null,
isSVG: boolean
isSVG: boolean,
optimized: boolean
) => void
type ProcessTextOrCommentFn = (
@@ -242,7 +243,8 @@ export type SetupRenderEffectFn = (
container: RendererElement,
anchor: RendererNode | null,
parentSuspense: SuspenseBoundary | null,
isSVG: boolean
isSVG: boolean,
optimized: boolean
) => void
export const enum MoveType {
@@ -961,7 +963,8 @@ function baseCreateRenderer(
anchor,
parentComponent,
parentSuspense,
isSVG
isSVG,
optimized
)
}
} else {
@@ -978,7 +981,7 @@ function baseCreateRenderer(
if (__DEV__) {
pushWarningContext(n2)
}
updateComponentPreRender(instance, n2)
updateComponentPreRender(instance, n2, optimized)
if (__DEV__) {
popWarningContext()
}
@@ -1006,7 +1009,8 @@ function baseCreateRenderer(
anchor,
parentComponent,
parentSuspense,
isSVG
isSVG,
optimized
) => {
const instance: ComponentInternalInstance = (initialVNode.component = createComponentInstance(
initialVNode,
@@ -1034,7 +1038,7 @@ function baseCreateRenderer(
if (__DEV__) {
startMeasure(instance, `init`)
}
setupComponent(instance, parentSuspense)
setupComponent(instance)
if (__DEV__) {
endMeasure(instance, `init`)
}
@@ -1063,7 +1067,8 @@ function baseCreateRenderer(
container,
anchor,
parentSuspense,
isSVG
isSVG,
optimized
)
if (__DEV__) {
@@ -1078,7 +1083,8 @@ function baseCreateRenderer(
container,
anchor,
parentSuspense,
isSVG
isSVG,
optimized
) => {
// create reactive effect for rendering
instance.update = effect(function componentEffect() {
@@ -1162,7 +1168,7 @@ function baseCreateRenderer(
}
if (next) {
updateComponentPreRender(instance, next)
updateComponentPreRender(instance, next, optimized)
} else {
next = vnode
}
@@ -1232,12 +1238,13 @@ function baseCreateRenderer(
const updateComponentPreRender = (
instance: ComponentInternalInstance,
nextVNode: VNode
nextVNode: VNode,
optimized: boolean
) => {
nextVNode.component = instance
instance.vnode = nextVNode
instance.next = null
resolveProps(instance, nextVNode.props)
updateProps(instance, nextVNode.props, optimized)
resolveSlots(instance, nextVNode.children)
}