From 456e0c5745633dd4ee192e16e14723baf9132922 Mon Sep 17 00:00:00 2001 From: edef Date: Thu, 5 May 2022 00:43:32 +0000 Subject: ripple/fossil/mount: terminate out-of-bounds Node::find early Node::find would walk the tree all the way down and to the right if given an out of bounds index. This doesn't affect the return value (None), but it does waste some cycles walking down all the way to the deepest rightmost leaf. Change-Id: Ic2f72aa96291a25819fc6c3c2f060fe0182a7663 --- ripple/fossil/src/bin/mount.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ripple/fossil/src/bin/mount.rs b/ripple/fossil/src/bin/mount.rs index f1bcdde..c9c5955 100644 --- a/ripple/fossil/src/bin/mount.rs +++ b/ripple/fossil/src/bin/mount.rs @@ -906,7 +906,7 @@ mod memtree { (0, _) => { break Some(root); } - (_, Node::Directory(d)) => { + (_, Node::Directory(d)) if index <= d.size => { index -= 1; d } -- cgit 1.4.1