@@ -247,6 +247,9 @@ class DirtyCheckingChangeDetectorGroup<H> implements ChangeDetectorGroup<H> {
247
247
248
248
class DirtyCheckingChangeDetector <H > extends DirtyCheckingChangeDetectorGroup <H >
249
249
implements ChangeDetector <H > {
250
+
251
+ final DirtyCheckingRecord _fakeHead = new DirtyCheckingRecord .marker ();
252
+
250
253
DirtyCheckingChangeDetector (GetterCache getterCache): super (null , getterCache);
251
254
252
255
DirtyCheckingChangeDetector get _root => this ;
@@ -278,24 +281,17 @@ class DirtyCheckingChangeDetector<H> extends DirtyCheckingChangeDetectorGroup<H>
278
281
return true ;
279
282
}
280
283
281
- Iterator <Record <H >> collectChanges ({ EvalExceptionHandler exceptionHandler,
282
- AvgStopwatch stopwatch}) {
284
+ Iterator <Record <H >> collectChanges ({EvalExceptionHandler exceptionHandler,
285
+ AvgStopwatch stopwatch}) {
283
286
if (stopwatch != null ) stopwatch.start ();
284
- DirtyCheckingRecord changeHead = null ;
285
- DirtyCheckingRecord changeTail = null ;
287
+ DirtyCheckingRecord changeTail = _fakeHead;
286
288
DirtyCheckingRecord current = _recordHead; // current index
287
289
288
290
int count = 0 ;
289
291
while (current != null ) {
290
292
try {
291
- if (current.check ()) {
292
- if (changeHead == null ) {
293
- changeHead = changeTail = current;
294
- } else {
295
- changeTail = changeTail._nextChange = current;
296
- }
297
- }
298
- if (stopwatch != null ) count++ ;
293
+ if (current.check ()) changeTail = changeTail._nextChange = current;
294
+ count++ ;
299
295
} catch (e, s) {
300
296
if (exceptionHandler == null ) {
301
297
rethrow ;
@@ -305,8 +301,12 @@ class DirtyCheckingChangeDetector<H> extends DirtyCheckingChangeDetectorGroup<H>
305
301
}
306
302
current = current._nextRecord;
307
303
}
308
- if (changeTail != null ) changeTail._nextChange = null ;
304
+
305
+ changeTail._nextChange = null ;
309
306
if (stopwatch != null ) stopwatch..stop ()..increment (count);
307
+ DirtyCheckingRecord changeHead = _fakeHead._nextChange;
308
+ _fakeHead._nextChange = null ;
309
+
310
310
return new _ChangeIterator (changeHead);
311
311
}
312
312
0 commit comments