From: Evan You Date: Wed, 21 Jul 2021 18:04:02 +0000 (-0400) Subject: perf: skip patch on same vnode X-Git-Tag: v3.2.0-beta.4~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d13774b881b297f2cd1a8d3193183d241dee625b;p=thirdparty%2Fvuejs%2Fcore.git perf: skip patch on same vnode --- diff --git a/packages/runtime-core/src/renderer.ts b/packages/runtime-core/src/renderer.ts index 4bf1f9038f..99eaf02bb6 100644 --- a/packages/runtime-core/src/renderer.ts +++ b/packages/runtime-core/src/renderer.ts @@ -470,6 +470,10 @@ function baseCreateRenderer( slotScopeIds = null, optimized = __DEV__ && isHmrUpdating ? false : !!n2.dynamicChildren ) => { + if (n1 === n2) { + return + } + // patching & not same type, unmount old tree if (n1 && !isSameVNodeType(n1, n2)) { anchor = getNextHostNode(n1) @@ -1152,8 +1156,12 @@ function baseCreateRenderer( const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''))! let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2 - if (dynamicChildren) { - optimized = true + + if (__DEV__ && isHmrUpdating) { + // HMR updated, force full diff + patchFlag = 0 + optimized = false + dynamicChildren = null } // check if this is a slot fragment with :slotted scope ids @@ -1163,13 +1171,6 @@ function baseCreateRenderer( : fragmentSlotScopeIds } - if (__DEV__ && isHmrUpdating) { - // HMR updated, force full diff - patchFlag = 0 - optimized = false - dynamicChildren = null - } - if (n1 == null) { hostInsert(fragmentStartAnchor, container, anchor) hostInsert(fragmentEndAnchor, container, anchor)