[system] Refactor sortContainerQueries to define regex outside of sort function by sai6855 · Pull Request #47817 · mui/material-ui (original) (raw)
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
zannager added the scope: system
The system, the design tokens / styling foundations used across components. eg. @mui/system with MUI
label
sai6855 marked this pull request as ready for review
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-widthmatchingRegExpout of the.sort()callback insortContainerQueries.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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?
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
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
