Skip to content

[system] Refactor sortContainerQueries to define regex outside of sort function#47817

Merged
sai6855 merged 6 commits into
mui:masterfrom
sai6855:move-regex
Mar 2, 2026
Merged

[system] Refactor sortContainerQueries to define regex outside of sort function#47817
sai6855 merged 6 commits into
mui:masterfrom
sai6855:move-regex

Conversation

@sai6855

@sai6855 sai6855 commented Feb 20, 2026

Copy link
Copy Markdown
Member

This pull request makes a minor change to the sortContainerQueries function in cssContainerQueries.ts by moving the regex declaration outside of the sorting callback as it's not required to create regex on every loop

@mui-bot

mui-bot commented Feb 20, 2026

Copy link
Copy Markdown

Netlify deploy preview

https://deploy-preview-47817--material-ui.netlify.app/

Bundle size report

Bundle Parsed size Gzip size
@mui/material ▼-14B(0.00%) ▼-2B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/system ▼-14B(-0.02%) ▼-7B(-0.03%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against 59fe337

@zannager zannager added the scope: system The system, the design tokens / styling foundations used across components. eg. @mui/system with MUI label Feb 26, 2026
@sai6855 sai6855 marked this pull request as ready for review February 27, 2026 16:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors sortContainerQueries in cssContainerQueries.ts to avoid re-creating the same RegExp on every sort comparator call, keeping behavior the same while reducing per-iteration work.

Changes:

  • Hoists the min-width matching RegExp out of the .sort() callback in sortContainerQueries.

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

@siriwatknp siriwatknp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

how about moving it outside of the function to avoid recreating on every call?

@siriwatknp siriwatknp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍 I'll let you decide on my comment

@sai6855

sai6855 commented Mar 2, 2026

Copy link
Copy Markdown
Member Author

Interestingly moving regex outside of function increased bundle-size by good amount, so For now i'm just going with keeping regex inside function but out of loop

image

@sai6855 sai6855 enabled auto-merge (squash) March 2, 2026 05:08
@sai6855 sai6855 merged commit 0abdbaa into mui:master Mar 2, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: system The system, the design tokens / styling foundations used across components. eg. @mui/system with MUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants