aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-07-14 14:58:32 +0100
committerGitHub <[email protected]>2020-07-14 14:58:32 +0100
commit5a25cc28204c6d02a5108b13568ec71914f096a5 (patch)
treed818819843fb2611e71da676aed25e269da64491
parentebb4d29d694f60f746a2b7b43980ba89cc9dc807 (diff)
parentdc2094cfa5b15bb5b915c5f1ba81535e45d0af22 (diff)
Merge #5372
5372: Minor, push allocations down r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r--baseline.tst12
-rw-r--r--crates/vfs/src/file_set.rs2
-rw-r--r--crates/vfs/src/lib.rs4
3 files changed, 15 insertions, 3 deletions
diff --git a/baseline.tst b/baseline.tst
new file mode 100644
index 000000000..c6e56e8c2
--- /dev/null
+++ b/baseline.tst
@@ -0,0 +1,12 @@
1 24ms - SourceRootConfig::partition
2 24ms - SourceRootConfig::partition
3 31ms - SourceRootConfig::partition
4 30ms - SourceRootConfig::partition
5 35ms - SourceRootConfig::partition
6 28ms - SourceRootConfig::partition
7 32ms - SourceRootConfig::partition
8 26ms - SourceRootConfig::partition
9 30ms - SourceRootConfig::partition
10 26ms - SourceRootConfig::partition
11 32ms - SourceRootConfig::partition
12 31ms - SourceRootConfig::partition
diff --git a/crates/vfs/src/file_set.rs b/crates/vfs/src/file_set.rs
index 37c479306..e5e2ef530 100644
--- a/crates/vfs/src/file_set.rs
+++ b/crates/vfs/src/file_set.rs
@@ -62,7 +62,7 @@ impl FileSetConfig {
62 let mut res = vec![FileSet::default(); self.len()]; 62 let mut res = vec![FileSet::default(); self.len()];
63 for (file_id, path) in vfs.iter() { 63 for (file_id, path) in vfs.iter() {
64 let root = self.classify(&path, &mut scratch_space); 64 let root = self.classify(&path, &mut scratch_space);
65 res[root].insert(file_id, path) 65 res[root].insert(file_id, path.clone())
66 } 66 }
67 res 67 res
68 } 68 }
diff --git a/crates/vfs/src/lib.rs b/crates/vfs/src/lib.rs
index 3bfecd08f..cdf6f1fd0 100644
--- a/crates/vfs/src/lib.rs
+++ b/crates/vfs/src/lib.rs
@@ -90,12 +90,12 @@ impl Vfs {
90 pub fn file_contents(&self, file_id: FileId) -> &[u8] { 90 pub fn file_contents(&self, file_id: FileId) -> &[u8] {
91 self.get(file_id).as_deref().unwrap() 91 self.get(file_id).as_deref().unwrap()
92 } 92 }
93 pub fn iter(&self) -> impl Iterator<Item = (FileId, VfsPath)> + '_ { 93 pub fn iter(&self) -> impl Iterator<Item = (FileId, &VfsPath)> + '_ {
94 (0..self.data.len()) 94 (0..self.data.len())
95 .map(|it| FileId(it as u32)) 95 .map(|it| FileId(it as u32))
96 .filter(move |&file_id| self.get(file_id).is_some()) 96 .filter(move |&file_id| self.get(file_id).is_some())
97 .map(move |file_id| { 97 .map(move |file_id| {
98 let path = self.interner.lookup(file_id).clone(); 98 let path = self.interner.lookup(file_id);
99 (file_id, path) 99 (file_id, path)
100 }) 100 })
101 } 101 }