From fa297196ef8a0743f929472d0ae2b7e902784612 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Wed, 18 Jan 2023 21:20:02 +0000 Subject: [PATCH] style: Reuse list_matches_complex_selector() where possible It can be reused for the Is, Where, and Negation components. Differential Revision: https://phabricator.services.mozilla.com/D166267 --- components/selectors/matching.rs | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/components/selectors/matching.rs b/components/selectors/matching.rs index a8f96daf086..16b491dcd5f 100644 --- a/components/selectors/matching.rs +++ b/components/selectors/matching.rs @@ -824,22 +824,12 @@ where nth_of_data.nth_data(), nth_of_data.selectors(), ), - Component::Is(ref list) | Component::Where(ref list) => context.shared.nest(|context| { - for selector in &**list { - if matches_complex_selector(selector.iter(), element, context) { - return true; - } - } - false - }), - Component::Negation(ref list) => context.shared.nest_for_negation(|context| { - for selector in &**list { - if matches_complex_selector(selector.iter(), element, context) { - return false; - } - } - true - }), + Component::Is(ref list) | Component::Where(ref list) => context + .shared + .nest(|context| list_matches_complex_selector(list, element, context)), + Component::Negation(ref list) => context + .shared + .nest_for_negation(|context| !list_matches_complex_selector(list, element, context)), Component::Has(ref list) => context .shared .nest(|context| has_children_matching(list, element, context)),