@@ -313,38 +313,23 @@ export function pause_effect(effect, callback = noop) {
313
313
* Pause multiple effects simultaneously, and coordinate their
314
314
* subsequent destruction. Used in each blocks
315
315
* @param {import('#client').Effect[] } effects
316
- * @returns { import('#client').TransitionManager[] }
316
+ * @param { () => void } callback
317
317
*/
318
- export function get_out_transitions ( effects ) {
318
+ export function pause_effects ( effects , callback = noop ) {
319
319
/** @type {import('#client').TransitionManager[] } */
320
320
var transitions = [ ] ;
321
+ var length = effects . length ;
321
322
322
- for ( var i = 0 ; i < effects . length ; i ++ ) {
323
+ for ( var i = 0 ; i < length ; i ++ ) {
323
324
pause_children ( effects [ i ] , transitions , true ) ;
324
325
}
325
326
326
- return transitions ;
327
- }
328
-
329
- /**
330
- * @param {import('#client').Effect[] } effects
331
- */
332
- export function destroy_effects ( effects ) {
333
- for ( var i = 0 ; i < effects . length ; i ++ ) {
334
- destroy_effect ( effects [ i ] ) ;
335
- }
336
- }
337
-
338
- /**
339
- * Pause multiple effects simultaneously, and coordinate their
340
- * subsequent destruction. Used in each blocks
341
- * @param {import('#client').Effect[] } effects
342
- * @param {import('#client').TransitionManager[] } transitions
343
- * @param {() => void } callback
344
- */
345
- export function pause_effects ( effects , transitions , callback = noop ) {
327
+ // TODO: would be good to avoid this closure in the case where we have no
328
+ // transitions at all. It would make it far more JIT friendly in the hot cases.
346
329
out ( transitions , ( ) => {
347
- destroy_effects ( effects ) ;
330
+ for ( var i = 0 ; i < length ; i ++ ) {
331
+ destroy_effect ( effects [ i ] ) ;
332
+ }
348
333
callback ( ) ;
349
334
} ) ;
350
335
}
@@ -385,12 +370,13 @@ function pause_children(effect, transitions, local) {
385
370
var child = effect . first ;
386
371
387
372
while ( child !== null ) {
373
+ var sibling = child . next ;
388
374
var transparent = ( child . f & IS_ELSEIF ) !== 0 || ( child . f & BRANCH_EFFECT ) !== 0 ;
389
375
// TODO we don't need to call pause_children recursively with a linked list in place
390
376
// it's slightly more involved though as we have to account for `transparent` changing
391
377
// through the tree.
392
378
pause_children ( child , transitions , transparent ? local : false ) ;
393
- child = child . next ;
379
+ child = sibling ;
394
380
}
395
381
}
396
382
0 commit comments