Skip to content

Commit 3610e91

Browse files
committed
perf: add back computed flags initialization past path
1 parent 4983199 commit 3610e91

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export function computed<T>(getter: (previousValue?: T) => T): () => T {
117117
subsTail: undefined,
118118
deps: undefined,
119119
depsTail: undefined,
120-
flags: 17 as ReactiveFlags.Mutable | ReactiveFlags.Dirty,
120+
flags: 0 as ReactiveFlags.None,
121121
getter: getter as (previousValue?: unknown) => unknown,
122122
}) as () => T;
123123
}
@@ -259,6 +259,14 @@ function computedOper<T>(this: Computed<T>): T {
259259
shallowPropagate(subs);
260260
}
261261
}
262+
} else if (!flags) {
263+
this.flags = 1 satisfies ReactiveFlags.Mutable;
264+
const prevSub = setActiveSub(this);
265+
try {
266+
this.value = this.getter();
267+
} finally {
268+
activeSub = prevSub;
269+
}
262270
}
263271
const sub = activeSub;
264272
if (sub !== undefined) {

0 commit comments

Comments
 (0)