@@ -394,31 +394,34 @@ function reconcile(array, state, anchor, render_fn, flags, get_key) {
394
394
395
395
const to_destroy = Array . from ( seen ) ;
396
396
397
- while ( current ) {
397
+ while ( current !== null ) {
398
398
to_destroy . push ( current ) ;
399
399
current = current . next ;
400
400
}
401
+ var destroy_length = to_destroy . length ;
401
402
402
- var controlled_anchor = ( flags & EACH_IS_CONTROLLED ) !== 0 && length === 0 ? anchor : null ;
403
+ if ( destroy_length > 0 ) {
404
+ var controlled_anchor = ( flags & EACH_IS_CONTROLLED ) !== 0 && length === 0 ? anchor : null ;
403
405
404
- if ( is_animated ) {
405
- for ( i = 0 ; i < to_destroy . length ; i += 1 ) {
406
- to_destroy [ i ] . a ?. measure ( ) ;
407
- }
406
+ if ( is_animated ) {
407
+ for ( i = 0 ; i < destroy_length ; i += 1 ) {
408
+ to_destroy [ i ] . a ?. measure ( ) ;
409
+ }
408
410
409
- for ( i = 0 ; i < to_destroy . length ; i += 1 ) {
410
- to_destroy [ i ] . a ?. fix ( ) ;
411
+ for ( i = 0 ; i < destroy_length ; i += 1 ) {
412
+ to_destroy [ i ] . a ?. fix ( ) ;
413
+ }
411
414
}
412
- }
413
415
414
- pause_effects ( to_destroy , controlled_anchor , ( ) => {
415
- for ( var i = 0 ; i < to_destroy . length ; i += 1 ) {
416
- var item = to_destroy [ i ] ;
417
- items . delete ( item . k ) ;
418
- item . o . remove ( ) ;
419
- link ( item . prev , item . next ) ;
420
- }
421
- } ) ;
416
+ pause_effects ( to_destroy , controlled_anchor , ( ) => {
417
+ for ( var i = 0 ; i < destroy_length ; i += 1 ) {
418
+ var item = to_destroy [ i ] ;
419
+ items . delete ( item . k ) ;
420
+ item . o . remove ( ) ;
421
+ link ( item . prev , item . next ) ;
422
+ }
423
+ } ) ;
424
+ }
422
425
423
426
if ( is_animated ) {
424
427
effect ( ( ) => {
0 commit comments