From 0fcaa3ce0393b713e38850ee8c83c3e105015daa Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 27 Mar 2015 19:00:50 -0700 Subject: [PATCH] script: Fix O(n^2) dirty bit marking when setting style on all immediate children of a node. --- components/script/dom/node.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 67bb5279f32..ae79327e7da 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -700,14 +700,16 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> { // // TODO(cgaebel): This is a very conservative way to account for sibling // selectors. Maybe we can do something smarter in the future. - let parent = - match self.parent_node() { - None => return, - Some(parent) => parent, - }; + if !self.get_has_dirty_siblings() { + let parent = + match self.parent_node() { + None => return, + Some(parent) => parent, + }; - for sibling in parent.root().r().children() { - sibling.set_has_dirty_siblings(true); + for sibling in parent.root().r().children() { + sibling.set_has_dirty_siblings(true); + } } // 4. Dirty ancestors.