Skip to content

Commit 3599670

Browse files
committed
refactor(system): move linkPool to System object for better encapsulation
1 parent 89c5e8f commit 3599670

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/system.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export const System = {
4545
lastTrackId: 0,
4646
queuedEffects: undefined as IEffect | undefined,
4747
queuedEffectsTail: undefined as IEffect | undefined,
48+
linkPool: undefined as Link | undefined,
4849
};
4950

5051
export function startBatch(): void {
@@ -74,8 +75,6 @@ export function drainQueuedEffects(): void {
7475
}
7576
}
7677

77-
let linkPool: Link | undefined = undefined;
78-
7978
export function link(dep: Dependency, sub: Subscriber): void {
8079
const depsTail = sub.depsTail;
8180
const old = depsTail !== undefined
@@ -85,9 +84,9 @@ export function link(dep: Dependency, sub: Subscriber): void {
8584
if (old === undefined || old.dep !== dep) {
8685
let newLink: Link;
8786

88-
if (linkPool !== undefined) {
89-
newLink = linkPool;
90-
linkPool = newLink.nextDep;
87+
if (System.linkPool !== undefined) {
88+
newLink = System.linkPool;
89+
System.linkPool = newLink.nextDep;
9190
newLink.nextDep = old;
9291
newLink.dep = dep;
9392
newLink.sub = sub;
@@ -376,8 +375,8 @@ export function clearTrack(link: Link): void {
376375
link.sub = undefined;
377376
link.prevSub = undefined;
378377
link.nextSub = undefined;
379-
link.nextDep = linkPool;
380-
linkPool = link;
378+
link.nextDep = System.linkPool;
379+
System.linkPool = link;
381380

382381
if (dep.subs === undefined && 'deps' in dep) {
383382
if ('notify' in dep) {

0 commit comments

Comments
 (0)