From bfc4ed4cac79192fd054ce9dd68a0bad13f854fb Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Thu, 12 Nov 2015 00:24:19 -0500 Subject: [PATCH] Cleanup PageIterator::next --- components/script/page.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/components/script/page.rs b/components/script/page.rs index 67cb1ca46ed..cedbb02bd74 100644 --- a/components/script/page.rs +++ b/components/script/page.rs @@ -100,15 +100,11 @@ impl Iterator for PageIterator { type Item = Rc; fn next(&mut self) -> Option> { - match self.stack.pop() { - Some(next) => { - for child in &*next.children.borrow() { - self.stack.push(child.clone()); - } - Some(next) - }, - None => None, + let popped = self.stack.pop(); + if let Some(ref page) = popped { + self.stack.extend(page.children.borrow().iter().cloned()); } + popped } }