Skip to content

Commit 12eb82d

Browse files
committed
Assign cache slot based on which dimensions are known
This gives huge performance wins on deep trees. On my machine, an improvement from 17s to 3ms (note change of unit) on the benchmark with 10,000 nodes at a depth of 14
1 parent 7913918 commit 12eb82d

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/compute/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ fn compute_node_layout(
112112
};
113113

114114
// Cache result
115+
let cache_slot = (known_dimensions.width.is_some() as usize) + (known_dimensions.height.is_some() as usize * 2);
115116
*tree.cache_mut(node, cache_slot) =
116117
Some(Cache { known_dimensions, available_space, run_mode: cache_run_mode, cached_size: computed_size });
117118

0 commit comments

Comments
 (0)