Clean up _extendComplex by removing a variable.

This commit is contained in:
Natalie Weizenbaum 2017-02-17 14:03:57 -08:00 committed by Natalie Weizenbaum
parent c006fd8f14
commit 454171d7a0

View File

@ -235,7 +235,6 @@ class Extender {
{bool replace: false}) { {bool replace: false}) {
// This could be written more simply using [List.map], but we want to avoid // This could be written more simply using [List.map], but we want to avoid
// any allocations in the common case where no extends apply. // any allocations in the common case where no extends apply.
var changed = false;
List<List<ComplexSelector>> extendedNotExpanded; List<List<ComplexSelector>> extendedNotExpanded;
for (var i = 0; i < complex.components.length; i++) { for (var i = 0; i < complex.components.length; i++) {
var component = complex.components[i]; var component = complex.components[i];
@ -243,33 +242,26 @@ class Extender {
var extended = _extendCompound(component, extensions, mediaQueryContext, var extended = _extendCompound(component, extensions, mediaQueryContext,
replace: replace); replace: replace);
if (extended == null) { if (extended == null) {
if (changed) { extendedNotExpanded?.add([
extendedNotExpanded.add([ new ComplexSelector([component])
new ComplexSelector([component]) ]);
]);
}
} else { } else {
if (!changed) { extendedNotExpanded ??= complex.components
extendedNotExpanded = complex.components .take(i)
.take(i) .map((component) => [
.map((component) => [ new ComplexSelector([component],
new ComplexSelector([component], lineBreak: complex.lineBreak)
lineBreak: complex.lineBreak) ])
]) .toList();
.toList();
}
changed = true;
extendedNotExpanded.add(extended); extendedNotExpanded.add(extended);
} }
} else { } else {
if (changed) { extendedNotExpanded?.add([
extendedNotExpanded.add([ new ComplexSelector([component])
new ComplexSelector([component]) ]);
]);
}
} }
} }
if (!changed) return null; if (extendedNotExpanded == null) return null;
var first = true; var first = true;
return paths(extendedNotExpanded).map((path) { return paths(extendedNotExpanded).map((path) {