improve pruning tree indexing logic
This commit is contained in:
parent
97d914238c
commit
86d4455321
@ -442,22 +442,15 @@ impl FutureMoves {
|
||||
self.arena = moves
|
||||
.into_iter()
|
||||
.map(|mut node| {
|
||||
if let Some(parent) = node.parent.as_mut() {
|
||||
if let Some(new_parent) = index_map[*parent] {
|
||||
*parent = new_parent;
|
||||
} else {
|
||||
// make sure we don't have dangling parents
|
||||
node.parent = None;
|
||||
}
|
||||
}
|
||||
node.parent = node
|
||||
.parent
|
||||
.and_then(|parent| index_map.get(parent).and_then(|&x| x));
|
||||
|
||||
for c in node.children.as_mut_slice() {
|
||||
debug_assert_ne!(
|
||||
index_map.get(*c).and_then(|&x| x),
|
||||
None,
|
||||
"index_map should contain the child's index"
|
||||
);
|
||||
*c = unsafe { index_map.get_unchecked(*c).unwrap_unchecked() };
|
||||
*c = index_map
|
||||
.get(*c)
|
||||
.and_then(|&x| x)
|
||||
.expect("index_map should contain the child's index");
|
||||
}
|
||||
|
||||
node
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user