From b9f3c5d585ee266f0fd5db77c2a3f331a0bddf2d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 19 Jun 2020 15:07:32 +0200 Subject: Speedup VFS::partition The task of `partition` function is to bin the flat list of paths into disjoint filesets. Ideally, it should be incremental -- each new file should be added to a specific fileset. However, preliminary measurnments show that it is actually fast enough if we just optimize this to use a binary search instead of a linear scan. --- crates/paths/src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'crates/paths') diff --git a/crates/paths/src/lib.rs b/crates/paths/src/lib.rs index c7ce0c42f..190c50913 100644 --- a/crates/paths/src/lib.rs +++ b/crates/paths/src/lib.rs @@ -2,7 +2,7 @@ //! relative paths. use std::{ convert::{TryFrom, TryInto}, - ops, + io, ops, path::{Component, Path, PathBuf}, }; @@ -46,6 +46,9 @@ impl TryFrom<&str> for AbsPathBuf { } impl AbsPathBuf { + pub fn canonicalized(path: &Path) -> io::Result { + path.canonicalize().map(|it| AbsPathBuf::try_from(it).unwrap()) + } pub fn as_path(&self) -> &AbsPath { AbsPath::new_unchecked(self.0.as_path()) } -- cgit v1.2.3