perf: skip normalizeVNode in optimized mode
This commit is contained in:
parent
8be578b6b6
commit
520af9787b
@ -319,7 +319,8 @@ export function createRenderer<
|
||||
anchor,
|
||||
parentComponent,
|
||||
parentSuspense,
|
||||
isSVG
|
||||
isSVG,
|
||||
optimized
|
||||
)
|
||||
} else {
|
||||
patchElement(n1, n2, parentComponent, parentSuspense, isSVG, optimized)
|
||||
@ -335,7 +336,8 @@ export function createRenderer<
|
||||
anchor: HostNode | null,
|
||||
parentComponent: ComponentInternalInstance | null,
|
||||
parentSuspense: HostSuspenseBoundary | null,
|
||||
isSVG: boolean
|
||||
isSVG: boolean,
|
||||
optimized: boolean
|
||||
) {
|
||||
const tag = vnode.type as string
|
||||
isSVG = isSVG || tag === 'svg'
|
||||
@ -359,7 +361,8 @@ export function createRenderer<
|
||||
null,
|
||||
parentComponent,
|
||||
parentSuspense,
|
||||
isSVG
|
||||
isSVG,
|
||||
optimized || vnode.dynamicChildren !== null
|
||||
)
|
||||
}
|
||||
hostInsert(el, container, anchor)
|
||||
@ -377,10 +380,13 @@ export function createRenderer<
|
||||
parentComponent: ComponentInternalInstance | null,
|
||||
parentSuspense: HostSuspenseBoundary | null,
|
||||
isSVG: boolean,
|
||||
optimized: boolean,
|
||||
start: number = 0
|
||||
) {
|
||||
for (let i = start; i < children.length; i++) {
|
||||
const child = (children[i] = normalizeVNode(children[i]))
|
||||
const child = optimized
|
||||
? (children[i] as HostVNode)
|
||||
: (children[i] = normalizeVNode(children[i]))
|
||||
patch(
|
||||
null,
|
||||
child,
|
||||
@ -388,7 +394,8 @@ export function createRenderer<
|
||||
anchor,
|
||||
parentComponent,
|
||||
parentSuspense,
|
||||
isSVG
|
||||
isSVG,
|
||||
optimized
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -620,7 +627,8 @@ export function createRenderer<
|
||||
fragmentEndAnchor,
|
||||
parentComponent,
|
||||
parentSuspense,
|
||||
isSVG
|
||||
isSVG,
|
||||
optimized
|
||||
)
|
||||
} else {
|
||||
patchChildren(
|
||||
@ -662,7 +670,8 @@ export function createRenderer<
|
||||
null,
|
||||
parentComponent,
|
||||
parentSuspense,
|
||||
isSVG
|
||||
isSVG,
|
||||
optimized
|
||||
)
|
||||
}
|
||||
} else if (__DEV__) {
|
||||
@ -1337,7 +1346,8 @@ export function createRenderer<
|
||||
anchor,
|
||||
parentComponent,
|
||||
parentSuspense,
|
||||
isSVG
|
||||
isSVG,
|
||||
optimized
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -1361,7 +1371,9 @@ export function createRenderer<
|
||||
const commonLength = Math.min(oldLength, newLength)
|
||||
let i
|
||||
for (i = 0; i < commonLength; i++) {
|
||||
const nextChild = (c2[i] = normalizeVNode(c2[i]))
|
||||
const nextChild = optimized
|
||||
? (c2[i] as HostVNode)
|
||||
: (c2[i] = normalizeVNode(c2[i]))
|
||||
patch(
|
||||
c1[i],
|
||||
nextChild,
|
||||
@ -1385,6 +1397,7 @@ export function createRenderer<
|
||||
parentComponent,
|
||||
parentSuspense,
|
||||
isSVG,
|
||||
optimized,
|
||||
commonLength
|
||||
)
|
||||
}
|
||||
@ -1411,7 +1424,9 @@ export function createRenderer<
|
||||
// (a b) d e
|
||||
while (i <= e1 && i <= e2) {
|
||||
const n1 = c1[i]
|
||||
const n2 = (c2[i] = normalizeVNode(c2[i]))
|
||||
const n2 = optimized
|
||||
? (c2[i] as HostVNode)
|
||||
: (c2[i] = normalizeVNode(c2[i]))
|
||||
if (isSameType(n1, n2)) {
|
||||
patch(
|
||||
n1,
|
||||
@ -1434,7 +1449,9 @@ export function createRenderer<
|
||||
// d e (b c)
|
||||
while (i <= e1 && i <= e2) {
|
||||
const n1 = c1[e1]
|
||||
const n2 = (c2[e2] = normalizeVNode(c2[e2]))
|
||||
const n2 = optimized
|
||||
? (c2[i] as HostVNode)
|
||||
: (c2[e2] = normalizeVNode(c2[e2]))
|
||||
if (isSameType(n1, n2)) {
|
||||
patch(
|
||||
n1,
|
||||
@ -1468,7 +1485,7 @@ export function createRenderer<
|
||||
while (i <= e2) {
|
||||
patch(
|
||||
null,
|
||||
(c2[i] = normalizeVNode(c2[i])),
|
||||
optimized ? (c2[i] as HostVNode) : (c2[i] = normalizeVNode(c2[i])),
|
||||
container,
|
||||
anchor,
|
||||
parentComponent,
|
||||
@ -1505,7 +1522,9 @@ export function createRenderer<
|
||||
// 5.1 build key:index map for newChildren
|
||||
const keyToNewIndexMap: Map<string | number, number> = new Map()
|
||||
for (i = s2; i <= e2; i++) {
|
||||
const nextChild = (c2[i] = normalizeVNode(c2[i]))
|
||||
const nextChild = optimized
|
||||
? (c2[i] as HostVNode)
|
||||
: (c2[i] = normalizeVNode(c2[i]))
|
||||
if (nextChild.key != null) {
|
||||
if (__DEV__ && keyToNewIndexMap.has(nextChild.key)) {
|
||||
warn(
|
||||
|
Loading…
x
Reference in New Issue
Block a user