pub(crate) struct NodeMatchContext<'a> {
pub is_disabled: bool,
pub type_index: Option<usize>,
pub type_count: Option<usize>,
pub own_siblings: Option<&'a [Node]>,
}Expand description
1 ノードに対して一度だけ計算すればよい照合用の前提情報。
【2026-07-27 性能修正】従来これらは matches_selector の内部で
ルールごとに毎回計算されていた。実サイト規模(2403 ルール × 365 ノード
= 約 88 万回)では、祖先を辿る is_node_disabled と兄弟を数える
type_sibling_position が支配的なコストになり、1 回のカスケードに
約 46 秒を要していた。ノード単位で 1 回計算して使い回す。
Fields§
§is_disabled: bool§type_index: Option<usize>§type_count: Option<usize>§own_siblings: Option<&'a [Node]>Implementations§
Source§impl<'a> NodeMatchContext<'a>
impl<'a> NodeMatchContext<'a>
pub fn new( current: &Node, ancestors: &'a [AncestorContext<'a>], sibling_index: Option<usize>, ) -> Self
Sourcepub fn with_type_position(
current: &Node,
ancestors: &'a [AncestorContext<'a>],
sibling_index: Option<usize>,
type_position: Option<(Option<usize>, Option<usize>)>,
) -> Self
pub fn with_type_position( current: &Node, ancestors: &'a [AncestorContext<'a>], sibling_index: Option<usize>, type_position: Option<(Option<usize>, Option<usize>)>, ) -> Self
type_position に親が先に数えた同じタグの兄弟の中の位置(type_positions_of_children)を渡せば、
兄弟を数え直さない(2026-11-18、TODO R5 (e) ④)。None なら type_sibling_position で数える。
Auto Trait Implementations§
impl<'a> Freeze for NodeMatchContext<'a>
impl<'a> RefUnwindSafe for NodeMatchContext<'a>
impl<'a> Send for NodeMatchContext<'a>
impl<'a> Sync for NodeMatchContext<'a>
impl<'a> Unpin for NodeMatchContext<'a>
impl<'a> UnsafeUnpin for NodeMatchContext<'a>
impl<'a> UnwindSafe for NodeMatchContext<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more