Skip to content

Commit

Permalink
Remove the heuristic where long selector lists wouldn't be trimmed
Browse files Browse the repository at this point in the history
Testing this against the `@extend`-heavy stylesheets in
vinceliuice/Colloid-gtk-theme, trimming everywhere actually *improves*
performance rather than reducing it.
  • Loading branch information
nex3 committed May 29, 2024
1 parent 5121eb1 commit a23f49b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.77.3

* Fully trim redundant selectors generated by `@extend`.

## 1.77.2

* Don't emit deprecation warnings for functions and mixins beginning with `__`.
Expand Down
7 changes: 0 additions & 7 deletions lib/src/extend/extension_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -901,13 +901,6 @@ class ExtensionStore {
// document, and thus should never be trimmed.
List<ComplexSelector> _trim(List<ComplexSelector> selectors,
bool isOriginal(ComplexSelector complex)) {
// Avoid truly horrific quadratic behavior.
//
// TODO(nweiz): I think there may be a way to get perfect trimming without
// going quadratic by building some sort of trie-like data structure that
// can be used to look up superselectors.
if (selectors.length > 100) return selectors;

// This is n² on the sequences, but only comparing between separate
// sequences should limit the quadratic behavior. We iterate from last to
// first and reverse the result so that, if two selectors are identical, we
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sass
version: 1.77.2
version: 1.77.3
description: A Sass implementation in Dart.
homepage: https://github.com/sass/dart-sass

Expand Down

0 comments on commit a23f49b

Please sign in to comment.