Inwerpsel / use-theme-editor

A React theme editor
GNU General Public License v3.0
4 stars 0 forks source link

More correct and efficient selector matching #21

Open Inwerpsel opened 1 year ago

Inwerpsel commented 1 year ago

The current matching algorithm works in a weird way, because of the assumptions at the time it was written.

With the recent render optimizations, the matching is now usually the bottleneck. Though in most cases it's still well below the performance budget. The worst case scenario (extract every rule on a very complex page) was still somewhat acceptable at about 150-200ms when inspecting an element with many ancestors. Though this does leave very little room to expand the tasks involved, and can probably be reduced to almost nothing, given all the selector testing duplication.

In the process, a less ad-hoc data model should probably be devised. Properties are currently being defined wherever they're needed first, with no type guarantees.

Inwerpsel commented 3 months ago

https://github.com/Inwerpsel/use-theme-editor/blob/5d3d5fdff2d37423820d71c8e63e9cd7ba4d892b/src/functions/parseCss.js