remove superfluous clone and indexing for loops from @extend
This commit is contained in:
parent
f7bb133cfd
commit
60c9327cf3
@ -208,9 +208,7 @@ impl Extender {
|
|||||||
// This could be written more simply using Vec<Vec<T>>, but we want to avoid
|
// This could be written more simply using Vec<Vec<T>>, 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.
|
||||||
let mut extended: Option<Vec<ComplexSelector>> = None;
|
let mut extended: Option<Vec<ComplexSelector>> = None;
|
||||||
for i in 0..list.components.len() {
|
for (i, complex) in list.components.iter().enumerate() {
|
||||||
let complex = list.components.get(i).unwrap().clone();
|
|
||||||
|
|
||||||
if let Some(result) =
|
if let Some(result) =
|
||||||
self.extend_complex(complex.clone(), extensions, media_query_context)
|
self.extend_complex(complex.clone(), extensions, media_query_context)
|
||||||
{
|
{
|
||||||
@ -226,7 +224,7 @@ impl Extender {
|
|||||||
None => unreachable!(),
|
None => unreachable!(),
|
||||||
}
|
}
|
||||||
} else if let Some(extended) = extended.as_mut() {
|
} else if let Some(extended) = extended.as_mut() {
|
||||||
extended.push(complex);
|
extended.push(complex.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,8 +268,8 @@ impl Extender {
|
|||||||
|
|
||||||
let complex_has_line_break = complex.line_break;
|
let complex_has_line_break = complex.line_break;
|
||||||
|
|
||||||
for i in 0..complex.components.len() {
|
for (i, component) in complex.components.iter().enumerate() {
|
||||||
if let Some(ComplexSelectorComponent::Compound(component)) = complex.components.get(i) {
|
if let ComplexSelectorComponent::Compound(component) = component {
|
||||||
if let Some(extended) =
|
if let Some(extended) =
|
||||||
self.extend_compound(component, extensions, media_query_context)
|
self.extend_compound(component, extensions, media_query_context)
|
||||||
{
|
{
|
||||||
@ -304,9 +302,7 @@ impl Extender {
|
|||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if let Some(component @ ComplexSelectorComponent::Combinator(..)) =
|
} else if component.is_combinator() {
|
||||||
complex.components.get(i)
|
|
||||||
{
|
|
||||||
match extended_not_expanded.as_mut() {
|
match extended_not_expanded.as_mut() {
|
||||||
Some(v) => v.push(vec![ComplexSelector {
|
Some(v) => v.push(vec![ComplexSelector {
|
||||||
components: vec![component.clone()],
|
components: vec![component.clone()],
|
||||||
@ -884,7 +880,7 @@ impl Extender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !self.extensions.is_empty() {
|
if !self.extensions.is_empty() {
|
||||||
selector = self.extend_list(selector.clone(), None, &media_query_context);
|
selector = self.extend_list(selector, None, &media_query_context);
|
||||||
/*
|
/*
|
||||||
todo: when we have error handling
|
todo: when we have error handling
|
||||||
} on SassException catch (error) {
|
} on SassException catch (error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user