Skip to content

fix: avoid using dev-mode array.includes wrapper on internal array checks#17536

Merged
Rich-Harris merged 3 commits intosveltejs:mainfrom
hmnd:push-mzsvoownzrqy
Jan 25, 2026
Merged

fix: avoid using dev-mode array.includes wrapper on internal array checks#17536
Rich-Harris merged 3 commits intosveltejs:mainfrom
hmnd:push-mzsvoownzrqy

Conversation

@hmnd
Copy link
Copy Markdown
Contributor

@hmnd hmnd commented Jan 25, 2026

The dev-mode warning wrapper on Array.includes induces a significant performance penalty on some hot paths in Svelte's internals. Eg. the slowest part in rendering this bar chart page (#17176 (comment)) in dev mode is the sources.includes in depends_on. This change gives me a roughly 4x improvement in rendering the bar chart page in dev.

This pr changes all usage of Array.includes in reactivity internals to use the un-wrapped index_of export instead. Only thing I'm not sure of is whether to use that index_of, or add a new re-export for array_includes.

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.
  • If this PR changes code within packages/svelte/src, add a changeset (npx changeset).

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jan 25, 2026

🦋 Changeset detected

Latest commit: d8c82f0

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

@github-actions
Copy link
Copy Markdown
Contributor

Playground

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

@hmnd hmnd force-pushed the push-mzsvoownzrqy branch from 76c97f1 to 1624cf9 Compare January 25, 2026 03:18
Copy link
Copy Markdown
Member

@Rich-Harris Rich-Harris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, thank you!

@Rich-Harris Rich-Harris merged commit bec90d4 into sveltejs:main Jan 25, 2026
14 checks passed
@github-actions github-actions bot mentioned this pull request Jan 25, 2026
@hmnd hmnd deleted the push-mzsvoownzrqy branch January 25, 2026 21:44
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