remove superfluous clones in weave()
This commit is contained in:
parent
05f5bc141a
commit
fc36a7a1e8
@ -66,28 +66,25 @@ pub(crate) fn unify_complex(
|
|||||||
///
|
///
|
||||||
/// The selector `.D (.A .B)` is represented as the list `[[.D], [.A, .B]]`.
|
/// The selector `.D (.A .B)` is represented as the list `[[.D], [.A, .B]]`.
|
||||||
pub(crate) fn weave(
|
pub(crate) fn weave(
|
||||||
complexes: Vec<Vec<ComplexSelectorComponent>>,
|
mut complexes: Vec<Vec<ComplexSelectorComponent>>,
|
||||||
) -> Vec<Vec<ComplexSelectorComponent>> {
|
) -> Vec<Vec<ComplexSelectorComponent>> {
|
||||||
let mut prefixes: Vec<Vec<ComplexSelectorComponent>> = vec![complexes.first().unwrap().clone()];
|
let mut prefixes: Vec<Vec<ComplexSelectorComponent>> = vec![complexes.remove(0)];
|
||||||
|
|
||||||
for complex in complexes.into_iter().skip(1) {
|
for mut complex in complexes.into_iter() {
|
||||||
if complex.is_empty() {
|
if complex.is_empty() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let target = complex.last().unwrap().clone();
|
let target = complex.pop().unwrap();
|
||||||
|
|
||||||
let complex_len = complex.len();
|
if complex.is_empty() {
|
||||||
|
|
||||||
if complex_len == 1 {
|
|
||||||
for prefix in &mut prefixes {
|
for prefix in &mut prefixes {
|
||||||
prefix.push(target.clone());
|
prefix.push(target.clone());
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let parents: Vec<ComplexSelectorComponent> =
|
let parents: Vec<ComplexSelectorComponent> = complex;
|
||||||
complex.into_iter().take(complex_len - 1).collect();
|
|
||||||
let mut new_prefixes: Vec<Vec<ComplexSelectorComponent>> = Vec::new();
|
let mut new_prefixes: Vec<Vec<ComplexSelectorComponent>> = Vec::new();
|
||||||
|
|
||||||
for prefix in prefixes {
|
for prefix in prefixes {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user