Skip to content

Commit c161427

Browse files
committed
chore: simplify process_effects
1 parent 280d8c7 commit c161427

File tree

1 file changed

+22
-33
lines changed

1 file changed

+22
-33
lines changed

packages/svelte/src/internal/client/runtime.js

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,6 @@ export function schedule_effect(signal) {
788788
*/
789789
function process_effects(effect, collected_effects) {
790790
var current_effect = effect.first;
791-
var effects = [];
792791

793792
main_loop: while (current_effect !== null) {
794793
var flags = current_effect.f;
@@ -797,34 +796,32 @@ function process_effects(effect, collected_effects) {
797796
var sibling = current_effect.next;
798797

799798
if (!is_skippable_branch && (flags & INERT) === 0) {
800-
if ((flags & RENDER_EFFECT) !== 0) {
801-
if (is_branch) {
802-
current_effect.f ^= CLEAN;
803-
} else {
804-
// Ensure we set the effect to be the active reaction
805-
// to ensure that unowned deriveds are correctly tracked
806-
// because we're flushing the current effect
807-
var previous_active_reaction = active_reaction;
808-
try {
809-
active_reaction = current_effect;
810-
if (check_dirtiness(current_effect)) {
811-
update_effect(current_effect);
812-
}
813-
} catch (error) {
814-
handle_error(error, current_effect, null, current_effect.ctx);
815-
} finally {
816-
active_reaction = previous_active_reaction;
799+
if ((flags & EFFECT) !== 0) {
800+
collected_effects.push(current_effect);
801+
} else if (is_branch) {
802+
current_effect.f ^= CLEAN;
803+
} else {
804+
// Ensure we set the effect to be the active reaction
805+
// to ensure that unowned deriveds are correctly tracked
806+
// because we're flushing the current effect
807+
var previous_active_reaction = active_reaction;
808+
try {
809+
active_reaction = current_effect;
810+
if (check_dirtiness(current_effect)) {
811+
update_effect(current_effect);
817812
}
813+
} catch (error) {
814+
handle_error(error, current_effect, null, current_effect.ctx);
815+
} finally {
816+
active_reaction = previous_active_reaction;
818817
}
818+
}
819819

820-
var child = current_effect.first;
820+
var child = current_effect.first;
821821

822-
if (child !== null) {
823-
current_effect = child;
824-
continue;
825-
}
826-
} else if ((flags & EFFECT) !== 0) {
827-
effects.push(current_effect);
822+
if (child !== null) {
823+
current_effect = child;
824+
continue;
828825
}
829826
}
830827

@@ -846,14 +843,6 @@ function process_effects(effect, collected_effects) {
846843

847844
current_effect = sibling;
848845
}
849-
850-
// We might be dealing with many effects here, far more than can be spread into
851-
// an array push call (callstack overflow). So let's deal with each effect in a loop.
852-
for (var i = 0; i < effects.length; i++) {
853-
child = effects[i];
854-
collected_effects.push(child);
855-
process_effects(child, collected_effects);
856-
}
857846
}
858847

859848
/**

0 commit comments

Comments
 (0)