improve update_root_coord

This commit is contained in:
Simon Gardling 2025-02-18 12:18:41 -05:00
parent 937a48f230
commit 8842bf6087
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D

View File

@ -262,9 +262,14 @@ impl FutureMoves {
self.arena
.iter()
.enumerate()
.find_map(|(idx, node)| {
(node.parent == self.current_root && node.i == i && node.j == j).then_some(idx)
.filter(|(_, node)| {
node.parent == self.current_root
&& self.current_root.is_some()
&& node.i == i
&& node.j == j
})
.next()
.map(|x| x.0)
.inspect(|&root| self.update_root_idx(root))
.is_some()
}