Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: optimize remove duplicated properties #852

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

vladitasev
Copy link

When the removeDuplicatedValues configuration setting is set to true, it is unavoidable to have two embedded loops to remove duplicates, as both the props and the values must be compared.

However, if only removeDuplicatedProperties is set to true, then duplicates can be removed with only one loop - iterate from the last node to the first, keep the first occurrence of each prop (as it will be the last in the CSS selector), and remove all others.

For large, programmatically generated selectors, most commonly :root { ... } and hundreds of CSS variables inside, this optimization can reduce the time needed by the plugin by a minute or more.

@ChristianMurphy
Copy link
Owner

Thanks @vladitasev!
Would you be able to take a look at why CI is failing with these changes?

@vladitasev
Copy link
Author

Hey @ChristianMurphy
Of course,
It was the line length - I needed to move the 2 comments to separate lines in order to satisfy the linter. The build should be passing now.

Copy link
Owner

@ChristianMurphy ChristianMurphy left a comment

Choose a reason for hiding this comment

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

Thanks @vladitasev!
LGTM, an ideas on how to test the performance characteristics to ensure no regressions come up?

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