perf: optimize public properties access on componentProxy

This commit is contained in:
Evan You 2019-12-19 14:19:47 -05:00
parent c73d889235
commit d6da48a33f

View File

@ -94,6 +94,7 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
// is the multiple hasOwn() calls. It's much faster to do a simple property // is the multiple hasOwn() calls. It's much faster to do a simple property
// access on a plain object, so we use an accessCache object (with null // access on a plain object, so we use an accessCache object (with null
// prototype) to memoize what access type a key corresponds to. // prototype) to memoize what access type a key corresponds to.
if (key[0] !== '$') {
const n = accessCache![key] const n = accessCache![key]
if (n !== undefined) { if (n !== undefined) {
switch (n) { switch (n) {
@ -118,6 +119,7 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
// return the value from propsProxy for ref unwrapping and readonly // return the value from propsProxy for ref unwrapping and readonly
return propsProxy![key] return propsProxy![key]
} }
}
// public $xxx properties & user-attached properties (sink) // public $xxx properties & user-attached properties (sink)
const publicGetter = publicPropertiesMap[key] const publicGetter = publicPropertiesMap[key]