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