Skip to content

Fix accumulating spread in transform function#211

Merged
jacobp100 merged 1 commit intostyled-components:masterfrom
wojtekmaj:no-accumulating-spread
Mar 30, 2026
Merged

Fix accumulating spread in transform function#211
jacobp100 merged 1 commit intostyled-components:masterfrom
wojtekmaj:no-accumulating-spread

Conversation

@wojtekmaj
Copy link
Copy Markdown
Contributor

Spread syntax should be avoided on accumulators (like those in .reduce) because it causes a time complexity of O(n^2).

Copilot AI review requested due to automatic review settings March 30, 2026 09:31
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 30, 2026

⚠️ No Changeset found

Latest commit: c07bc9f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

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

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the core transform implementation (default export) that converts an array of CSS-style tuples into a React Native style object, with the stated goal of improving accumulator performance.

Changes:

  • Replaced the Array.reduce-based accumulator with an explicit for...of loop and a preallocated result object.
  • Preserved the existing per-rule merge behavior via Object.assign into the accumulator object.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Spread syntax should be avoided on accumulators (like those in `.reduce`) because it causes a time complexity of `O(n^2)`.
@wojtekmaj wojtekmaj force-pushed the no-accumulating-spread branch from c07bc9f to 9b6ae6d Compare March 30, 2026 09:34
@jacobp100 jacobp100 merged commit 3f4899b into styled-components:master Mar 30, 2026
5 checks passed
@jacobp100
Copy link
Copy Markdown
Contributor

@wojtekmaj If you know anybody in SC that's got permissions to add you as a contributor to this repo, I'd be happy for you to be added. Unfortunately I only have permission to approve & merge PRs

@wojtekmaj wojtekmaj deleted the no-accumulating-spread branch March 30, 2026 10:01
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.

3 participants