perf: avoid deopt for props/emits normalization when global mixins are used

This commit is contained in:
Evan You
2021-06-02 15:22:52 -04:00
parent e2ca67b59a
commit 51d2be2038
5 changed files with 35 additions and 28 deletions

View File

@@ -436,8 +436,10 @@ export function normalizePropsOptions(
appContext: AppContext,
asMixin = false
): NormalizedPropsOptions {
if (!appContext.deopt && comp.__props) {
return comp.__props
const cache = appContext.propsCache
const cached = cache.get(comp)
if (cached) {
return cached
}
const raw = comp.props
@@ -468,7 +470,8 @@ export function normalizePropsOptions(
}
if (!raw && !hasExtends) {
return (comp.__props = EMPTY_ARR as any)
cache.set(comp, EMPTY_ARR as any)
return EMPTY_ARR as any
}
if (isArray(raw)) {
@@ -506,7 +509,9 @@ export function normalizePropsOptions(
}
}
return (comp.__props = [normalized, needCastKeys])
const res: NormalizedPropsOptions = [normalized, needCastKeys]
cache.set(comp, res)
return res
}
function validatePropName(key: string) {