Skip to content

refactor: optimize remove duplicated properties#852

Open
vladitasev wants to merge 4 commits into
ChristianMurphy:mainfrom
vladitasev:optimize-properties-dup
Open

refactor: optimize remove duplicated properties#852
vladitasev wants to merge 4 commits into
ChristianMurphy:mainfrom
vladitasev:optimize-properties-dup

Conversation

@vladitasev

Copy link
Copy Markdown

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
Copy Markdown
Owner

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

@vladitasev

Copy link
Copy Markdown
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.

@ChristianMurphy ChristianMurphy left a comment

Copy link
Copy Markdown
Owner

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