Skip to content

Commit

Permalink
Revert the core of #2255 (#2511)
Browse files Browse the repository at this point in the history
This was causing serious performance issues in places where `@extend`
was used heavily with a large number of extenders.

Closes #2504
  • Loading branch information
nex3 authored Feb 12, 2025
1 parent 97bb2a7 commit f766f43
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
## 1.84.1-dev
## 1.85.0-dev

* No user-visible changes.

* No longer fully trim redundant selectors generated by `@extend`. This caused
unacceptable performance issues for certain heavy users of `@extend`. We'll
try to find a more performant way to accomplish it in the future.

## 1.84.0

* Allow newlines in whitespace in the indented syntax.
Expand Down
7 changes: 7 additions & 0 deletions lib/src/extend/extension_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,13 @@ 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 pkg/sass_api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 15.1.1-dev
## 15.2.0-dev

* No user-visible changes.

Expand Down
4 changes: 2 additions & 2 deletions pkg/sass_api/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ name: sass_api
# Note: Every time we add a new Sass AST node, we need to bump the *major*
# version because it's a breaking change for anyone who's implementing the
# visitor interface(s).
version: 15.1.1-dev
version: 15.2.0-dev
description: Additional APIs for Dart Sass.
homepage: https://github.com/sass/dart-sass

environment:
sdk: ">=3.3.0 <4.0.0"

dependencies:
sass: 1.84.1
sass: 1.85.0

dev_dependencies:
dartdoc: ^8.0.14
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.84.1-dev
version: 1.85.0-dev
description: A Sass implementation in Dart.
homepage: https://github.com/sass/dart-sass

Expand Down

0 comments on commit f766f43

Please sign in to comment.