From dc2094cfa5b15bb5b915c5f1ba81535e45d0af22 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 14 Jul 2020 15:57:10 +0200 Subject: [PATCH] Minor, push allocations down --- baseline.tst | 12 ++++++++++++ crates/vfs/src/file_set.rs | 2 +- crates/vfs/src/lib.rs | 4 ++-- 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 baseline.tst diff --git a/baseline.tst b/baseline.tst new file mode 100644 index 0000000000..c6e56e8c26 --- /dev/null +++ b/baseline.tst @@ -0,0 +1,12 @@ + 24ms - SourceRootConfig::partition + 24ms - SourceRootConfig::partition + 31ms - SourceRootConfig::partition + 30ms - SourceRootConfig::partition + 35ms - SourceRootConfig::partition + 28ms - SourceRootConfig::partition + 32ms - SourceRootConfig::partition + 26ms - SourceRootConfig::partition + 30ms - SourceRootConfig::partition + 26ms - SourceRootConfig::partition + 32ms - SourceRootConfig::partition + 31ms - SourceRootConfig::partition diff --git a/crates/vfs/src/file_set.rs b/crates/vfs/src/file_set.rs index 37c479306e..e5e2ef5307 100644 --- a/crates/vfs/src/file_set.rs +++ b/crates/vfs/src/file_set.rs @@ -62,7 +62,7 @@ impl FileSetConfig { let mut res = vec![FileSet::default(); self.len()]; for (file_id, path) in vfs.iter() { let root = self.classify(&path, &mut scratch_space); - res[root].insert(file_id, path) + res[root].insert(file_id, path.clone()) } res } diff --git a/crates/vfs/src/lib.rs b/crates/vfs/src/lib.rs index 3bfecd08fb..cdf6f1fd02 100644 --- a/crates/vfs/src/lib.rs +++ b/crates/vfs/src/lib.rs @@ -90,12 +90,12 @@ impl Vfs { pub fn file_contents(&self, file_id: FileId) -> &[u8] { self.get(file_id).as_deref().unwrap() } - pub fn iter(&self) -> impl Iterator + '_ { + pub fn iter(&self) -> impl Iterator + '_ { (0..self.data.len()) .map(|it| FileId(it as u32)) .filter(move |&file_id| self.get(file_id).is_some()) .map(move |file_id| { - let path = self.interner.lookup(file_id).clone(); + let path = self.interner.lookup(file_id); (file_id, path) }) }