diff options
author | Florian Klink <flokli@flokli.de> | 2024-04-13T12·53+0300 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-04-13T13·20+0000 |
commit | b70e01a4dbf3a4057a38593f6657893a1f9e5120 (patch) | |
tree | 6fc683df547d1b3974616276594bb22ac9d17167 /tvix | |
parent | a919efbe117242ef3386efd6ef3282571792fb30 (diff) |
feat(tvix/castore/import): remove copying in find_ancestor r/7910
We don't need to copy if we explicitly say that the returned Option<Path> may hold onto bytes from the passed in &DirEntry. Change-Id: Ib46b6fd2f8f19a45f8bef79c4c1d2fa6b490cad7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11410 Autosubmit: flokli <flokli@flokli.de> Reviewed-by: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix')
-rw-r--r-- | tvix/castore/src/import.rs | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/tvix/castore/src/import.rs b/tvix/castore/src/import.rs index a7034af19f5c..f78029ee0e3a 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)) } } |