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