From 1ede7d0f7f5761d69e6bfe7d5bf2d1d2a312b06d Mon Sep 17 00:00:00 2001 From: Glint Dev Date: Fri, 24 Jul 2026 16:46:31 +0300 Subject: [PATCH] phase 7.2/7.4: add compute_batch and matching_rules_batch for parallel style processing --- src/interpreter/style.rs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/interpreter/style.rs b/src/interpreter/style.rs index f03c95f..1580875 100644 --- a/src/interpreter/style.rs +++ b/src/interpreter/style.rs @@ -689,6 +689,36 @@ impl StyleSheet { Some(props) } + #[cfg(feature = "parallel")] + pub fn matching_rules_batch<'a>( + &'a self, + type_names: &[&str], + el_ids: &[Option<&str>], + el_classes_list: &[&[&str]], + active_pseudo_list: &[&[&str]], + structural_list: &[&StructuralContext], + ancestors_list: &[&[AncestorInfo]], + preceding_siblings_list: &[&[AncestorInfo]], + el_attributes_list: &[&HashMap], + ) -> Vec>> { + use rayon::prelude::*; + (0..type_names.len()) + .into_par_iter() + .map(|i| { + self.matching_rules( + type_names[i], + el_ids[i], + el_classes_list[i], + active_pseudo_list[i], + structural_list[i], + ancestors_list[i], + preceding_siblings_list[i], + el_attributes_list[i], + ) + }) + .collect() + } + pub fn matching_pseudo_rules( &self, pseudo: &str, @@ -951,6 +981,14 @@ let overflow = lookup("overflow", inline, matched_sheets).and_then(parse_overflo } } + #[cfg(feature = "parallel")] + pub fn compute_batch<'a>( + pairs: &[(&[(Cow<'_, str>, Cow<'_, str>)], &[&'a HashMap])], + ) -> Vec { + use rayon::prelude::*; + pairs.par_iter().map(|(inline, sheets)| Self::compute(inline, sheets)).collect() + } + pub fn apply_overrides(&mut self, sheet: &HashMap) { struct Override<'a>(&'a HashMap); impl<'a> Override<'a> {