about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tvix/castore/src/import.rs10
1 files changed, 2 insertions, 8 deletions
diff --git a/tvix/castore/src/import.rs b/tvix/castore/src/import.rs
index a7034af19f..f78029ee0e 100644
--- a/tvix/castore/src/import.rs
+++ b/tvix/castore/src/import.rs
@@ -284,14 +284,8 @@ impl MerkleInvariantChecker {
     }
 
     /// Returns a potential ancestor already seen for that directory entry.
-    fn find_ancestor(&self, node: &DirEntry) -> Option<PathBuf> {
-        for anc in node.path().ancestors() {
-            if self.seen.contains(anc) {
-                return Some(anc.to_owned());
-            }
-        }
-
-        None
+    fn find_ancestor<'a>(&self, node: &'a DirEntry) -> Option<&'a Path> {
+        node.path().ancestors().find(|p| self.seen.contains(*p))
     }
 }