Skip to content

chore: simplify component pop #16331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 10, 2025
Merged

chore: simplify component pop #16331

merged 8 commits into from
Jul 10, 2025

Conversation

Rich-Harris
Copy link
Member

couple of changes here:

  • the only time an effect gets deferred is if it's a top-level $effect. when pop runs, the current active effect/reaction are the same as they were when the effect was declared, so the set_active_effect and set_active_reaction calls are no-ops. By extension, we don't need to stash the current active effect/reaction, and we don't need to wrap the effect creation in a try-catch
  • since we don't need to stash the effect/reaction, component_context.e can just be an array of functions rather than an array of objects — less memory usage for components with effects
  • we can identify a top-level $effect because the current active_effect is a BRANCH_EFFECT, and the current active_reaction is null. These conditions do not obtain in any other circumstances. Consequently, we can remove the m flag — it's unnecessary. This saves more memory

Copy link

changeset-bot bot commented Jul 10, 2025

🦋 Changeset detected

Latest commit: 97092d2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

Playground

pnpm add https://pkg.pr.new/svelte@16331

@dummdidumm
Copy link
Member

Since this changes a bite more we should add a change set

@Rich-Harris Rich-Harris merged commit 8da222f into main Jul 10, 2025
14 checks passed
@Rich-Harris Rich-Harris deleted the simplify-pop branch July 10, 2025 12:57
@github-actions github-actions bot mentioned this pull request Jul 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants