Skip to content

Commit

Permalink
find_node_by_unique_id should use find
Browse files Browse the repository at this point in the history
find_node_by_unique_id should use find instead of for-loop
  • Loading branch information
dlrobertson committed Feb 24, 2016
1 parent 83b2388 commit cad3115
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions components/script/webdriver_handlers.rs
Expand Up @@ -40,15 +40,7 @@ use util::str::DOMString;
fn find_node_by_unique_id(page: &Rc<Page>, pipeline: PipelineId, node_id: String) -> Option<Root<Node>> {
let page = get_page(&*page, pipeline);
let document = page.document();
let node = document.upcast::<Node>();

for candidate in node.traverse_preorder() {
if candidate.get_unique_id() == node_id {
return Some(candidate);
}
}

None
document.upcast::<Node>().traverse_preorder().find(|candidate| candidate.get_unique_id() == node_id)
}

#[allow(unsafe_code)]
Expand Down

0 comments on commit cad3115

Please sign in to comment.