Skip to content

Commit cf019e5

Browse files
committed
perf: don't use ?.
1 parent 09a5b4a commit cf019e5

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/computed.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ export class Computed<T = any> implements IComputed {
3737
this.update();
3838
}
3939
const activeTrackId = System.activeTrackId;
40-
if (activeTrackId !== 0 && this.subsTail?.trackId !== activeTrackId) {
41-
Dependency.link(this, System.activeSub!);
40+
if (activeTrackId !== 0) {
41+
const subsTail = this.subsTail;
42+
if (subsTail === undefined || subsTail.trackId !== activeTrackId) {
43+
Dependency.link(this, System.activeSub!);
44+
}
4245
}
4346
return this.cachedValue!;
4447
}

src/signal.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ export class Signal<T = any> implements Dependency {
2222

2323
get() {
2424
const activeTrackId = System.activeTrackId;
25-
if (activeTrackId !== 0 && this.subsTail?.trackId !== activeTrackId) {
26-
Dependency.link(this, System.activeSub!);
25+
if (activeTrackId !== 0) {
26+
const subsTail = this.subsTail;
27+
if (subsTail === undefined || subsTail.trackId !== activeTrackId) {
28+
Dependency.link(this, System.activeSub!);
29+
}
2730
}
2831
return this.currentValue!;
2932
}

0 commit comments

Comments
 (0)