Simplify PrecedingNodeIterator::next().

This commit is contained in:
Ms2ger 2016-04-11 10:29:32 +02:00
parent 0d732ebb5f
commit 71f56d6744

View file

@ -1166,34 +1166,20 @@ impl Iterator for PrecedingNodeIterator {
Some(current) => current, Some(current) => current,
}; };
if self.root == current { self.current = if self.root == current {
self.current = None;
return None
}
let node = current;
if let Some(previous_sibling) = node.GetPreviousSibling() {
if self.root == previous_sibling {
self.current = None;
return None
}
if let Some(last_child) = previous_sibling.descending_last_children().last() {
self.current = Some(last_child);
return previous_sibling.descending_last_children().last()
}
self.current = Some(previous_sibling);
return node.GetPreviousSibling()
};
if let Some(parent_node) = node.GetParentNode() {
self.current = Some(parent_node);
return node.GetParentNode()
}
self.current = None;
None None
} else if let Some(previous_sibling) = current.GetPreviousSibling() {
if self.root == previous_sibling {
None
} else if let Some(last_child) = previous_sibling.descending_last_children().last() {
Some(last_child)
} else {
Some(previous_sibling)
}
} else {
current.GetParentNode()
};
self.current.clone()
} }
} }