perf(reactivity): optimize effect stack
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { effect, ReactiveEffect, effectStack } from './effect'
|
||||
import { effect, ReactiveEffect, activeEffect } from './effect'
|
||||
import { Ref, UnwrapRef } from './ref'
|
||||
import { isFunction, NOOP } from '@vue/shared'
|
||||
|
||||
@@ -73,15 +73,14 @@ export function computed<T>(
|
||||
}
|
||||
|
||||
function trackChildRun(childRunner: ReactiveEffect) {
|
||||
if (effectStack.length === 0) {
|
||||
if (activeEffect === undefined) {
|
||||
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)
|
||||
if (!dep.has(activeEffect)) {
|
||||
dep.add(activeEffect)
|
||||
activeEffect.deps.push(dep)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user