diff options
author | Aleksey Kladov <[email protected]> | 2019-02-18 11:13:13 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-02-18 11:13:13 +0000 |
commit | 4c154c289e3c18c2517ab8ce91e1d61f45f70388 (patch) | |
tree | 9bb92aca50f1df3404466d1fb6f54d5d97494290 /crates/ra_vfs/src/lib.rs | |
parent | d151b2a655057b9da45243d0f4e160b10a98ac37 (diff) |
remove arena from Roots
we want to move ra_vfs to a new repo, so having fewer deps is useful.
Arena is a thin layer of sugar on top of Vec anyway.
Diffstat (limited to 'crates/ra_vfs/src/lib.rs')
-rw-r--r-- | crates/ra_vfs/src/lib.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/ra_vfs/src/lib.rs b/crates/ra_vfs/src/lib.rs index 7f555a3c0..1c5402aed 100644 --- a/crates/ra_vfs/src/lib.rs +++ b/crates/ra_vfs/src/lib.rs | |||
@@ -25,7 +25,7 @@ use std::{ | |||
25 | }; | 25 | }; |
26 | 26 | ||
27 | use crossbeam_channel::Receiver; | 27 | use crossbeam_channel::Receiver; |
28 | use ra_arena::{impl_arena_id, Arena, RawId, map::ArenaMap}; | 28 | use ra_arena::{impl_arena_id, Arena, RawId}; |
29 | use relative_path::{RelativePath, RelativePathBuf}; | 29 | use relative_path::{RelativePath, RelativePathBuf}; |
30 | use rustc_hash::{FxHashMap, FxHashSet}; | 30 | use rustc_hash::{FxHashMap, FxHashSet}; |
31 | 31 | ||
@@ -53,7 +53,7 @@ struct VfsFileData { | |||
53 | pub struct Vfs { | 53 | pub struct Vfs { |
54 | roots: Arc<Roots>, | 54 | roots: Arc<Roots>, |
55 | files: Arena<VfsFile, VfsFileData>, | 55 | files: Arena<VfsFile, VfsFileData>, |
56 | root2files: ArenaMap<VfsRoot, FxHashSet<VfsFile>>, | 56 | root2files: FxHashMap<VfsRoot, FxHashSet<VfsFile>>, |
57 | pending_changes: Vec<VfsChange>, | 57 | pending_changes: Vec<VfsChange>, |
58 | worker: Worker, | 58 | worker: Worker, |
59 | } | 59 | } |
@@ -72,7 +72,7 @@ impl Vfs { | |||
72 | pub fn new(roots: Vec<PathBuf>) -> (Vfs, Vec<VfsRoot>) { | 72 | pub fn new(roots: Vec<PathBuf>) -> (Vfs, Vec<VfsRoot>) { |
73 | let roots = Arc::new(Roots::new(roots)); | 73 | let roots = Arc::new(Roots::new(roots)); |
74 | let worker = io::start(Arc::clone(&roots)); | 74 | let worker = io::start(Arc::clone(&roots)); |
75 | let mut root2files = ArenaMap::default(); | 75 | let mut root2files = FxHashMap::default(); |
76 | 76 | ||
77 | for root in roots.iter() { | 77 | for root in roots.iter() { |
78 | root2files.insert(root, Default::default()); | 78 | root2files.insert(root, Default::default()); |
@@ -164,7 +164,7 @@ impl Vfs { | |||
164 | let mut cur_files = Vec::new(); | 164 | let mut cur_files = Vec::new(); |
165 | // While we were scanning the root in the background, a file might have | 165 | // While we were scanning the root in the background, a file might have |
166 | // been open in the editor, so we need to account for that. | 166 | // been open in the editor, so we need to account for that. |
167 | let existing = self.root2files[root] | 167 | let existing = self.root2files[&root] |
168 | .iter() | 168 | .iter() |
169 | .map(|&file| (self.files[file].path.clone(), file)) | 169 | .map(|&file| (self.files[file].path.clone(), file)) |
170 | .collect::<FxHashMap<_, _>>(); | 170 | .collect::<FxHashMap<_, _>>(); |
@@ -241,7 +241,7 @@ impl Vfs { | |||
241 | ) -> VfsFile { | 241 | ) -> VfsFile { |
242 | let data = VfsFileData { root, path, text, is_overlayed }; | 242 | let data = VfsFileData { root, path, text, is_overlayed }; |
243 | let file = self.files.alloc(data); | 243 | let file = self.files.alloc(data); |
244 | self.root2files.get_mut(root).unwrap().insert(file); | 244 | self.root2files.get_mut(&root).unwrap().insert(file); |
245 | file | 245 | file |
246 | } | 246 | } |
247 | 247 | ||
@@ -256,7 +256,7 @@ impl Vfs { | |||
256 | self.files[file].text = Default::default(); | 256 | self.files[file].text = Default::default(); |
257 | self.files[file].path = Default::default(); | 257 | self.files[file].path = Default::default(); |
258 | let root = self.files[file].root; | 258 | let root = self.files[file].root; |
259 | let removed = self.root2files.get_mut(root).unwrap().remove(&file); | 259 | let removed = self.root2files.get_mut(&root).unwrap().remove(&file); |
260 | assert!(removed); | 260 | assert!(removed); |
261 | } | 261 | } |
262 | 262 | ||
@@ -267,7 +267,7 @@ impl Vfs { | |||
267 | } | 267 | } |
268 | 268 | ||
269 | fn find_file(&self, root: VfsRoot, path: &RelativePath) -> Option<VfsFile> { | 269 | fn find_file(&self, root: VfsRoot, path: &RelativePath) -> Option<VfsFile> { |
270 | self.root2files[root].iter().map(|&it| it).find(|&file| self.files[file].path == path) | 270 | self.root2files[&root].iter().map(|&it| it).find(|&file| self.files[file].path == path) |
271 | } | 271 | } |
272 | } | 272 | } |
273 | 273 | ||