perf: avoid using WeakSet for isRef check

This commit is contained in:
Evan You
2019-09-30 10:52:50 -04:00
parent 7f06981f7c
commit 46bd9dbab0
4 changed files with 11 additions and 18 deletions

View File

@@ -1,15 +1,15 @@
import { effect, ReactiveEffect, activeReactiveEffectStack } from './effect'
import { UnwrapNestedRefs, isRefSymbol, knownRefs } from './ref'
import { UnwrapNestedRefs } from './ref'
import { isFunction } from '@vue/shared'
export interface ComputedRef<T> {
[isRefSymbol]: true
_isRef: true
readonly value: UnwrapNestedRefs<T>
readonly effect: ReactiveEffect
}
export interface WritableComputedRef<T> {
[isRefSymbol]: true
_isRef: true
value: UnwrapNestedRefs<T>
readonly effect: ReactiveEffect
}
@@ -45,7 +45,8 @@ export function computed<T>(
dirty = true
}
})
const computedRef = {
return {
_isRef: true,
// expose effect so computed can be stopped
effect: runner,
get value() {
@@ -67,8 +68,6 @@ export function computed<T>(
}
}
}
knownRefs.add(computedRef)
return computedRef
}
function trackChildRun(childRunner: ReactiveEffect) {