Skip to content

perf: optimize simple object destructuring in @const tags#18390

Open
omecreates wants to merge 2 commits into
sveltejs:mainfrom
omecreates:perf/optimize-const-tag
Open

perf: optimize simple object destructuring in @const tags#18390
omecreates wants to merge 2 commits into
sveltejs:mainfrom
omecreates:perf/optimize-const-tag

Conversation

@omecreates

Copy link
Copy Markdown

This PR resolves a TODO in ConstTag.js regarding the optimization of simple object pattern matching cases like {@const { x } = y}.

Previously, this case forced the destructuring and subsequent repackaging of identical properties into a new object. This PR introduces a check (is_simple_object_pattern) to identify when an ObjectPattern contains only simple Property nodes matching keys to values without defaults or renaming. When this condition is met, the block now simply returns the right-hand-side initialization expression directly, avoiding the unnecessary reallocation.

(Also includes a minor typo fix in acorn.js)

@changeset-bot

changeset-bot Bot commented Jun 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e0c9836

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

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.

1 participant