diff options
author | Canop <cano.petrole@gmail.com> | 2020-11-30 22:23:07 +0100 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2020-11-30 22:23:07 +0100 |
commit | 4f0632a74bfc11e3eebcc04ae6fede1a690ea606 (patch) | |
tree | 5e40ca065448352f683af0d850fb9312de9b7f43 /src/tree | |
parent | 2fd09de426e8f7623180a834244330a0ec3f069a (diff) |
better cache management for dir size computation
Makes it faster in 2 common cases:
- compute the root size when children already computed
- going up one level in the tree
Diffstat (limited to 'src/tree')
-rw-r--r-- | src/tree/tree.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/tree/tree.rs b/src/tree/tree.rs index c7670e1..977d6ad 100644 --- a/src/tree/tree.rs +++ b/src/tree/tree.rs @@ -366,6 +366,8 @@ impl Tree { /// To compute the size of all of them, this should be called until /// has_dir_missing_sum returns false pub fn fetch_some_missing_dir_sum(&mut self, dam: &Dam) { + // we prefer to compute the root directory last: its computation + // is faster when its first level children are already computed for i in (0..self.lines.len()).rev() { if self.lines[i].sum.is_none() && self.lines[i].line_type == TreeLineType::Dir { self.lines[i].sum = FileSum::from_dir(&self.lines[i].path, dam); |