perf: revert to _isRef for perf

Benchmarking shows checking for a plain property is about 4~5x faster
than checking for a Symbol, likely because the Symbol does not fit well
into V8's hidden class model.
This commit is contained in:
Evan You
2019-10-16 21:36:17 -04:00
parent 6c80e13986
commit cdee65aa1b
2 changed files with 6 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
import { effect, ReactiveEffect, activeReactiveEffectStack } from './effect'
import { Ref, refSymbol, UnwrapRef } from './ref'
import { Ref, UnwrapRef } from './ref'
import { isFunction, NOOP } from '@vue/shared'
export interface ComputedRef<T> extends WritableComputedRef<T> {
@@ -46,7 +46,7 @@ export function computed<T>(
}
})
return {
[refSymbol]: true,
_isRef: true,
// expose effect so computed can be stopped
effect: runner,
get value() {