From ae88b3ed24c637873cb3e39beea91af2aa5c1511 Mon Sep 17 00:00:00 2001 From: connorskees Date: Sat, 7 Jan 2023 04:48:38 +0000 Subject: [PATCH] optimize has_following_sibling --- grass_internal/src/evaluate/css_tree.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/grass_internal/src/evaluate/css_tree.rs b/grass_internal/src/evaluate/css_tree.rs index e0208e8..bcf0e5d 100644 --- a/grass_internal/src/evaluate/css_tree.rs +++ b/grass_internal/src/evaluate/css_tree.rs @@ -129,13 +129,8 @@ impl CssTree { let parent_children = self.parent_to_child.get(parent_idx).unwrap(); - let child_pos = parent_children - .iter() - .position(|child_idx| *child_idx == child) - .unwrap(); - - // todo: parent_children[child_pos + 1..] !is_invisible - child_pos + 1 < parent_children.len() + // todo: we shouldn't take into account children that are invisible + parent_children.last() != Some(&child) } pub fn add_stmt(&mut self, child: CssStmt, parent: Option) -> CssTreeIdx {