perf: minor tweaks

This commit is contained in:
Evan You
2019-10-16 23:12:57 -04:00
parent 4771319a15
commit e3b68972d8
3 changed files with 19 additions and 21 deletions

View File

@@ -1,4 +1,4 @@
import { effect, ReactiveEffect, activeReactiveEffectStack } from './effect'
import { effect, ReactiveEffect, effectStack } from './effect'
import { Ref, UnwrapRef } from './ref'
import { isFunction, NOOP } from '@vue/shared'
@@ -67,15 +67,15 @@ export function computed<T>(
}
function trackChildRun(childRunner: ReactiveEffect) {
const parentRunner =
activeReactiveEffectStack[activeReactiveEffectStack.length - 1]
if (parentRunner) {
for (let i = 0; i < childRunner.deps.length; i++) {
const dep = childRunner.deps[i]
if (!dep.has(parentRunner)) {
dep.add(parentRunner)
parentRunner.deps.push(dep)
}
if (effectStack.length === 0) {
return
}
const parentRunner = effectStack[effectStack.length - 1]
for (let i = 0; i < childRunner.deps.length; i++) {
const dep = childRunner.deps[i]
if (!dep.has(parentRunner)) {
dep.add(parentRunner)
parentRunner.deps.push(dep)
}
}
}