From 2252be416e473221c425041bb26dbefa5eb27d90 Mon Sep 17 00:00:00 2001 From: nat Date: Thu, 26 Dec 2024 17:33:45 -0400 Subject: [PATCH] fix: don't adjust parent tree's stack size when composting --- src/bin/ponderosa-cpu.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/bin/ponderosa-cpu.rs b/src/bin/ponderosa-cpu.rs index de012b3..54edf8b 100644 --- a/src/bin/ponderosa-cpu.rs +++ b/src/bin/ponderosa-cpu.rs @@ -234,7 +234,14 @@ fn main() -> io::Result<()> { let tree = trees.remove(&tree_id).unwrap(); (tree.parent_id, tree.stack_size) }; - let parent = trees.get_mut(&parent_id).unwrap(); + + // One tree is "its own" parent, namely, the seed tree, in which + // case this `get_mut` will return None + let parent = match trees.get_mut(&parent_id) { + Some(p) => p, + None => continue + }; + parent.stack_size += recovered_stack_size; }