[system] Refactor sortContainerQueries to define regex outside of sort function by sai6855 · Pull Request #47817 · mui/material-ui (original) (raw)

@sai6855

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

@sai6855

@mui-bot

@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

@sai6855 sai6855 marked this pull request as ready for review

February 27, 2026 16:45

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:


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

siriwatknp

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

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

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

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 }})