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

Improve performance of control comments in postcss-custom-properties #737

Merged

Conversation

romainmenke
Copy link
Member

@romainmenke romainmenke commented Nov 29, 2022

closes : #730

@marvinhagemeister After discussing this with @Antonio-Laguna we decided to keep the functionality but to improve performance sufficiently.

We found that the performance issue only happens in fairly large code bases with large numbers of custom properties.

This change has three parts :

  • more efficient way to gather and parse custom properties from html/:root elements
  • more efficient way to check if a control comment exists
  • caching the existence of control comments in a WeakMap.

With these changes the overhead of the feature becomes negligible.
O(n^2) -> O(n)

Copy link
Member

@Antonio-Laguna Antonio-Laguna left a comment

Choose a reason for hiding this comment

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

This does look good to me!

Thanks!

@romainmenke romainmenke merged commit 00e0779 into main Nov 30, 2022
@romainmenke romainmenke deleted the custom-props--perf--sympathetic-pond-skater-e2e4815efd branch November 30, 2022 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants