Skip to content
Snippets Groups Projects
Commit 6fed1b7d authored by rarbore2's avatar rarbore2
Browse files

Fix LCA calculation in dom tree

parent 62b32318
No related branches found
No related tags found
1 merge request!54Fix LCA calculation in dom tree
......@@ -82,6 +82,9 @@ impl DomTree {
* ancestor of the two nodes that is as far down the tree as possible.
*/
pub fn least_common_ancestor(&self, mut a: NodeID, mut b: NodeID) -> NodeID {
if a == self.root || b == self.root {
return self.root;
}
while self.idom[&a].0 > self.idom[&b].0 {
a = self.idom[&a].1;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment