@@ -69,53 +69,7 @@ export function endBatch(): void {
69
69
}
70
70
}
71
71
72
- let pool : Link | undefined = undefined ;
73
-
74
- export function getLink ( dep : Dependency , sub : Subscriber , nextDep : Link | undefined ) : Link {
75
- if ( pool !== undefined ) {
76
- const newLink = pool ;
77
- pool = newLink . nextDep ;
78
- newLink . nextDep = nextDep ;
79
- newLink . dep = dep ;
80
- newLink . sub = sub ;
81
- newLink . trackId = sub . trackId ;
82
- return newLink ;
83
- }
84
- return {
85
- dep,
86
- sub,
87
- trackId : sub . trackId ,
88
- nextDep : nextDep ,
89
- prevSub : undefined ,
90
- nextSub : undefined ,
91
- } ;
92
- }
93
-
94
- export function releaseLink ( link : Link ) : void {
95
- const nextSub = link . nextSub ;
96
- const prevSub = link . prevSub ;
97
-
98
- if ( nextSub !== undefined ) {
99
- nextSub . prevSub = prevSub ;
100
- } else {
101
- link . dep . subsTail = prevSub ;
102
- }
103
-
104
- if ( prevSub !== undefined ) {
105
- prevSub . nextSub = nextSub ;
106
- } else {
107
- link . dep . subs = nextSub ;
108
- }
109
-
110
- // @ts -expect-error
111
- link . dep = undefined ;
112
- // @ts -expect-error
113
- link . sub = undefined ;
114
- link . prevSub = undefined ;
115
- link . nextSub = undefined ;
116
- link . nextDep = pool ;
117
- pool = link ;
118
- }
72
+ let linkPool : Link | undefined = undefined ;
119
73
120
74
export function link ( dep : Dependency , sub : Subscriber ) : void {
121
75
const depsTail = sub . depsTail ;
@@ -124,7 +78,25 @@ export function link(dep: Dependency, sub: Subscriber): void {
124
78
: sub . deps ;
125
79
126
80
if ( old === undefined || old . dep !== dep ) {
127
- const newLink = getLink ( dep , sub , old ) ;
81
+ let newLink : Link ;
82
+
83
+ if ( linkPool !== undefined ) {
84
+ newLink = linkPool ;
85
+ linkPool = newLink . nextDep ;
86
+ newLink . nextDep = old ;
87
+ newLink . dep = dep ;
88
+ newLink . sub = sub ;
89
+ newLink . trackId = sub . trackId ;
90
+ } else {
91
+ newLink = {
92
+ dep,
93
+ sub,
94
+ trackId : sub . trackId ,
95
+ nextDep : old ,
96
+ prevSub : undefined ,
97
+ nextSub : undefined ,
98
+ } ;
99
+ }
128
100
129
101
if ( depsTail === undefined ) {
130
102
sub . deps = newLink ;
@@ -378,7 +350,30 @@ export function clearTrack(link: Link): void {
378
350
do {
379
351
const dep = link . dep ;
380
352
const nextDep = link . nextDep ;
381
- releaseLink ( link ) ;
353
+ const nextSub = link . nextSub ;
354
+ const prevSub = link . prevSub ;
355
+
356
+ if ( nextSub !== undefined ) {
357
+ nextSub . prevSub = prevSub ;
358
+ } else {
359
+ link . dep . subsTail = prevSub ;
360
+ }
361
+
362
+ if ( prevSub !== undefined ) {
363
+ prevSub . nextSub = nextSub ;
364
+ } else {
365
+ link . dep . subs = nextSub ;
366
+ }
367
+
368
+ // @ts -expect-error
369
+ link . dep = undefined ;
370
+ // @ts -expect-error
371
+ link . sub = undefined ;
372
+ link . prevSub = undefined ;
373
+ link . nextSub = undefined ;
374
+ link . nextDep = linkPool ;
375
+ linkPool = link ;
376
+
382
377
if ( dep . subs === undefined && 'deps' in dep ) {
383
378
if ( 'notify' in dep ) {
384
379
dep . dirtyLevel = DirtyLevels . None ;
0 commit comments