Skip to content

Commit f766f43

Browse files
authored
Revert the core of #2255 (#2511)
This was causing serious performance issues in places where `@extend` was used heavily with a large number of extenders. Closes #2504
1 parent 97bb2a7 commit f766f43

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
## 1.84.1-dev
1+
## 1.85.0-dev
22

33
* No user-visible changes.
44

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

711
* Allow newlines in whitespace in the indented syntax.

lib/src/extend/extension_store.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,13 @@ class ExtensionStore {
901901
// document, and thus should never be trimmed.
902902
List<ComplexSelector> _trim(List<ComplexSelector> selectors,
903903
bool isOriginal(ComplexSelector complex)) {
904+
// Avoid truly horrific quadratic behavior.
905+
//
906+
// TODO(nweiz): I think there may be a way to get perfect trimming without
907+
// going quadratic by building some sort of trie-like data structure that
908+
// can be used to look up superselectors.
909+
if (selectors.length > 100) return selectors;
910+
904911
// This is n² on the sequences, but only comparing between separate
905912
// sequences should limit the quadratic behavior. We iterate from last to
906913
// first and reverse the result so that, if two selectors are identical, we

pkg/sass_api/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## 15.1.1-dev
1+
## 15.2.0-dev
22

33
* No user-visible changes.
44

pkg/sass_api/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ name: sass_api
22
# Note: Every time we add a new Sass AST node, we need to bump the *major*
33
# version because it's a breaking change for anyone who's implementing the
44
# visitor interface(s).
5-
version: 15.1.1-dev
5+
version: 15.2.0-dev
66
description: Additional APIs for Dart Sass.
77
homepage: https://github.com/sass/dart-sass
88

99
environment:
1010
sdk: ">=3.3.0 <4.0.0"
1111

1212
dependencies:
13-
sass: 1.84.1
13+
sass: 1.85.0
1414

1515
dev_dependencies:
1616
dartdoc: ^8.0.14

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sass
2-
version: 1.84.1-dev
2+
version: 1.85.0-dev
33
description: A Sass implementation in Dart.
44
homepage: https://github.com/sass/dart-sass
55

0 commit comments

Comments
 (0)