]> git.lizzy.rs Git - rust.git/commitdiff
Replace HashMap, HashSet with FxHashMap and FxHashSet
authorMuhammad Mominul Huque <mominul2082@gmail.com>
Thu, 11 Oct 2018 18:07:44 +0000 (00:07 +0600)
committerMuhammad Mominul Huque <mominul2082@gmail.com>
Thu, 11 Oct 2018 18:07:44 +0000 (00:07 +0600)
20 files changed:
Cargo.lock
crates/ra_analysis/Cargo.toml
crates/ra_analysis/src/db/imp.rs
crates/ra_analysis/src/imp.rs
crates/ra_analysis/src/lib.rs
crates/ra_analysis/src/roots.rs
crates/ra_analysis/tests/tests.rs
crates/ra_editor/Cargo.toml
crates/ra_editor/src/completion.rs
crates/ra_editor/src/folding_ranges.rs
crates/ra_editor/src/lib.rs
crates/ra_editor/src/scope/fn_scope.rs
crates/ra_lsp_server/Cargo.toml
crates/ra_lsp_server/src/lib.rs
crates/ra_lsp_server/src/main_loop/handlers.rs
crates/ra_lsp_server/src/main_loop/mod.rs
crates/ra_lsp_server/src/main_loop/subscriptions.rs
crates/ra_lsp_server/src/project_model.rs
crates/ra_lsp_server/src/req.rs
crates/ra_lsp_server/src/server_world.rs

index 256821a2e1b6253e882fd58e414253de54b2eba9..62feeb539ef2fdd199c0e0f6137991a6f93c3d1b 100644 (file)
@@ -540,6 +540,7 @@ dependencies = [
  "ra_syntax 0.1.0",
  "rayon 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "relative-path 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "salsa 0.1.0",
  "test_utils 0.1.0",
 ]
@@ -563,6 +564,7 @@ dependencies = [
  "itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "join_to_string 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "ra_syntax 0.1.0",
+ "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "superslice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "test_utils 0.1.0",
 ]
@@ -585,6 +587,7 @@ dependencies = [
  "ra_syntax 0.1.0",
  "rayon 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "relative-path 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_json 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -727,6 +730,14 @@ name = "rustc-demangle"
 version = "0.1.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
+[[package]]
+name = "rustc-hash"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
 [[package]]
 name = "rustc_version"
 version = "0.2.3"
@@ -1241,6 +1252,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum ron 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9fa11b7a38511d46ff1959ae46ebb60bd8a746f17bdd0206b4c8de7559ac47b"
 "checksum rowan 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4a1a7366ece9deee5e7df8316a136d585d5c5042854c2297f7f1aee3014c9130"
 "checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395"
+"checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8"
 "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
 "checksum ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7153dd96dade874ab973e098cb62fcdbb89a03682e46b144fd09550998d4a4a7"
 "checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9"
index a30cdfc9c510a85a0cc53fa79c9e9bf4a3696f23..a82e1761c2874e6a0b5ba2092ded0df01dc131ac 100644 (file)
@@ -15,6 +15,7 @@ im = "12.0.0"
 ra_syntax = { path = "../ra_syntax" }
 ra_editor = { path = "../ra_editor" }
 salsa = { path = "../salsa" }
+rustc-hash = "1.0"
 
 [dev-dependencies]
 test_utils = { path = "../test_utils" }
index f26be104638a152ca18f204e2a5be6167199dfcb..36f6cf2907ef6c3681f988660a0e512d19bf7bc4 100644 (file)
@@ -2,9 +2,10 @@
     sync::Arc,
     any::Any,
     hash::{Hash, Hasher},
-    collections::hash_map::{DefaultHasher, HashMap},
+    collections::hash_map::{DefaultHasher},
     iter,
 };
+use rustc_hash::FxHashMap;
 use salsa;
 use {FileId, imp::FileResolverImp};
 use super::{State, Query, QueryCtx};
@@ -13,7 +14,7 @@
 
 #[derive(Debug)]
 pub(super) struct Db {
-    names: Arc<HashMap<salsa::QueryTypeId, &'static str>>,
+    names: Arc<FxHashMap<salsa::QueryTypeId, &'static str>>,
     pub(super) imp: salsa::Db<State, Data>,
 }
 
@@ -85,7 +86,7 @@ fn get(&self, ctx: &QueryCtx, params: Self::Params) -> Arc<Self::Output> {
 
 pub(super) struct QueryRegistry {
     config: Option<salsa::QueryConfig<State, Data>>,
-    names: HashMap<salsa::QueryTypeId, &'static str>,
+    names: FxHashMap<salsa::QueryTypeId, &'static str>,
 }
 
 impl QueryRegistry {
@@ -109,7 +110,7 @@ pub(super) fn new() -> QueryRegistry {
                 (Arc::new(res), fingerprint)
             })
         );
-        let mut names = HashMap::new();
+        let mut names = FxHashMap::default();
         names.insert(FILE_TEXT, "FILE_TEXT");
         names.insert(FILE_SET, "FILE_SET");
         QueryRegistry { config: Some(config), names }
index 517867e86708fbbe8c72bf7ced6abca28f20a941..47bc0032bf58a07539b4643dc09fa8d7f7e0e70c 100644 (file)
@@ -4,11 +4,12 @@
         atomic::{AtomicBool, Ordering::SeqCst},
     },
     fmt,
-    collections::{HashSet, VecDeque},
+    collections::VecDeque,
     iter,
 };
 
 use relative_path::RelativePath;
+use rustc_hash::FxHashSet;
 use ra_editor::{self, FileSymbol, LineIndex, find_node_at_offset, LocalEdit, resolve_local_name};
 use ra_syntax::{
     TextUnit, TextRange, SmolStr, File, AstNode,
@@ -84,7 +85,7 @@ pub fn set_file_resolver(&mut self, resolver: FileResolverImp) {
         data.root = Arc::new(data.root.apply_changes(&mut iter::empty(), Some(resolver)));
     }
     pub fn set_crate_graph(&mut self, graph: CrateGraph) {
-        let mut visited = HashSet::new();
+        let mut visited = FxHashSet::default();
         for &file_id in graph.crate_roots.values() {
             if !visited.insert(file_id) {
                 panic!("duplicate crate root: {:?}", file_id);
@@ -168,7 +169,7 @@ pub fn crate_for(&self, file_id: FileId) -> Vec<CrateId> {
         let mut res = Vec::new();
         let mut work = VecDeque::new();
         work.push_back(file_id);
-        let mut visited = HashSet::new();
+        let mut visited = FxHashSet::default();
         while let Some(id) = work.pop_front() {
             if let Some(crate_id) = crate_graph.crate_id_for_crate_root(id) {
                 res.push(crate_id);
index f6ceb7eb255d6fa48ff885ca1e64acb2b37d9942..849fd93e42749aef086975e59c752d1a71913d84 100644 (file)
@@ -11,6 +11,7 @@
 extern crate crossbeam_channel;
 extern crate im;
 extern crate salsa;
+extern crate rustc_hash;
 
 mod symbol_index;
 mod module_map;
 
 use std::{
     sync::Arc,
-    collections::HashMap,
     fmt::Debug,
 };
 
 use relative_path::{RelativePath, RelativePathBuf};
 use ra_syntax::{File, TextRange, TextUnit, AtomEdit};
 use imp::{AnalysisImpl, AnalysisHostImpl, FileResolverImp};
+use rustc_hash::FxHashMap;
 
 pub use ra_editor::{
     StructureNode, LineIndex, FileSymbol,
@@ -46,7 +47,7 @@
 
 #[derive(Debug, Clone, Default)]
 pub struct CrateGraph {
-    pub crate_roots: HashMap<CrateId, FileId>,
+    pub crate_roots: FxHashMap<CrateId, FileId>,
 }
 
 pub trait FileResolver: Debug + Send + Sync + 'static {
index 1835a9b25988dc8c0a7bd27ddfb7bd93f86d7e88..32a8c5bd05f8a7208cd0077fa5d4f9dccb9626ea 100644 (file)
@@ -1,11 +1,11 @@
 use std::{
-    collections::HashMap,
     sync::Arc,
     panic,
 };
 
 use once_cell::sync::OnceCell;
 use rayon::prelude::*;
+use rustc_hash::FxHashMap;
 use ra_editor::LineIndex;
 use ra_syntax::File;
 
@@ -118,7 +118,7 @@ fn syntax(&self) -> &File {
 #[derive(Debug)]
 pub(crate) struct ReadonlySourceRoot {
     symbol_index: Arc<SymbolIndex>,
-    file_map: HashMap<FileId, FileData>,
+    file_map: FxHashMap<FileId, FileData>,
     module_tree: Arc<ModuleTreeDescriptor>,
 }
 
@@ -139,7 +139,7 @@ pub(crate) fn new(files: Vec<(FileId, String)>, file_resolver: FileResolverImp)
         let symbol_index = SymbolIndex::for_files(
             modules.par_iter().map(|it| (it.0, it.1.clone()))
         );
-        let file_map: HashMap<FileId, FileData> = files
+        let file_map: FxHashMap<FileId, FileData> = files
             .into_iter()
             .map(|(id, text)| (id, FileData::new(text)))
             .collect();
index 334dc5e485896b9ce03413a0c6068fe227c898c6..a886cd0ff72027820ff8c8c590e59b8d4bc3cecb 100644 (file)
@@ -1,12 +1,13 @@
 extern crate relative_path;
 extern crate ra_analysis;
+extern crate rustc_hash;
 extern crate test_utils;
 
 use std::{
     sync::Arc,
-    collections::HashMap,
 };
 
+use rustc_hash::FxHashMap;
 use relative_path::{RelativePath, RelativePathBuf};
 use ra_analysis::{Analysis, AnalysisHost, FileId, FileResolver, JobHandle, CrateGraph, CrateId};
 use test_utils::assert_eq_dbg;
@@ -131,7 +132,7 @@ fn test_resolve_crate_root() {
 
     let crate_graph = CrateGraph {
         crate_roots: {
-            let mut m = HashMap::new();
+            let mut m = FxHashMap::default();
             m.insert(CrateId(1), FileId(1));
             m
         },
index 40e3254ffacc3e071b45afc4f1bfea6e5682792b..91cefc8d7696c915bfd167f46d8102d020ce09e6 100644 (file)
@@ -8,6 +8,7 @@ publish = false
 itertools = "0.7.8"
 superslice = "0.1.0"
 join_to_string = "0.1.1"
+rustc-hash = "1.0"
 
 ra_syntax = { path = "../ra_syntax" }
 
index 570d72d66876a1d4297a9e5760f601e7d4dbd489..20b8484b339b8cb99a3681a0a5dd299d3dc956bc 100644 (file)
@@ -1,4 +1,4 @@
-use std::collections::{HashSet, HashMap};
+use rustc_hash::{FxHashMap, FxHashSet};
 
 use ra_syntax::{
     File, TextUnit, AstNode, SyntaxNodeRef, SyntaxKind::*,
@@ -96,7 +96,7 @@ fn complete_name_ref(file: &File, name_ref: ast::NameRef, acc: &mut Vec<Completi
 }
 
 fn param_completions(ctx: SyntaxNodeRef, acc: &mut Vec<CompletionItem>) {
-    let mut params = HashMap::new();
+    let mut params = FxHashMap::default();
     for node in ctx.ancestors() {
         let _ = visitor_ctx(&mut params)
             .visit::<ast::Root, _>(process)
@@ -114,7 +114,7 @@ fn param_completions(ctx: SyntaxNodeRef, acc: &mut Vec<CompletionItem>) {
             })
         });
 
-    fn process<'a, N: ast::FnDefOwner<'a>>(node: N, params: &mut HashMap<String, (u32, ast::Param<'a>)>) {
+    fn process<'a, N: ast::FnDefOwner<'a>>(node: N, params: &mut FxHashMap<String, (u32, ast::Param<'a>)>) {
         node.functions()
             .filter_map(|it| it.param_list())
             .flat_map(|it| it.params())
@@ -232,7 +232,7 @@ fn complete_mod_item_snippets(acc: &mut Vec<CompletionItem>) {
 }
 
 fn complete_fn(name_ref: ast::NameRef, scopes: &FnScopes, acc: &mut Vec<CompletionItem>) {
-    let mut shadowed = HashSet::new();
+    let mut shadowed = FxHashSet::default();
     acc.extend(
         scopes.scope_chain(name_ref.syntax())
             .flat_map(|scope| scopes.entries(scope).iter())
index 733512368ef574f51a2ffa59962940d7e81e28a6..3aabd54ae40bbfd111226f4418ef8d9cf994cb48 100644 (file)
@@ -1,4 +1,4 @@
-use std::collections::HashSet;
+use rustc_hash::FxHashSet;
 
 use ra_syntax::{
     File, TextRange, SyntaxNodeRef,
@@ -20,7 +20,7 @@ pub struct Fold {
 
 pub fn folding_ranges(file: &File) -> Vec<Fold> {
     let mut res = vec![];
-    let mut visited = HashSet::new();
+    let mut visited = FxHashSet::default();
 
     for node in file.syntax().descendants() {
         if visited.contains(&node) {
@@ -56,7 +56,7 @@ pub fn folding_ranges(file: &File) -> Vec<Fold> {
 fn contiguous_range_for<'a>(
     kind: SyntaxKind,
     node: SyntaxNodeRef<'a>,
-    visited: &mut HashSet<SyntaxNodeRef<'a>>,
+    visited: &mut FxHashSet<SyntaxNodeRef<'a>>,
 ) -> Option<TextRange> {
     visited.insert(node);
 
index 906ee11fe7f63e8f8db9dcb54f321156ffe8be6a..710afc65d557d4dabb4b056625307457c04b1457 100644 (file)
@@ -2,6 +2,7 @@
 extern crate superslice;
 extern crate itertools;
 extern crate join_to_string;
+extern crate rustc_hash;
 #[cfg(test)]
 #[macro_use]
 extern crate test_utils as _test_utils;
index 65d85279f5d58c3633d28dd52b36a2491ea31fd4..9a48bda020d4a52c19d3a466f00556a1ffcb16d2 100644 (file)
@@ -1,7 +1,5 @@
-use std::{
-    fmt,
-    collections::HashMap,
-};
+use std::fmt;
+use rustc_hash::FxHashMap;
 
 use ra_syntax::{
     SyntaxNodeRef, SyntaxNode, SmolStr, AstNode,
@@ -15,7 +13,7 @@
 pub struct FnScopes {
     pub self_param: Option<SyntaxNode>,
     scopes: Vec<ScopeData>,
-    scope_for: HashMap<SyntaxNode, ScopeId>,
+    scope_for: FxHashMap<SyntaxNode, ScopeId>,
 }
 
 impl FnScopes {
@@ -25,7 +23,7 @@ pub fn new(fn_def: ast::FnDef) -> FnScopes {
                 .and_then(|it| it.self_param())
                 .map(|it| it.syntax().owned()),
             scopes: Vec::new(),
-            scope_for: HashMap::new()
+            scope_for: FxHashMap::default()
         };
         let root = scopes.root_scope();
         scopes.add_params_bindings(root, fn_def.param_list());
@@ -242,9 +240,9 @@ struct ScopeData {
 }
 
 pub fn resolve_local_name<'a>(name_ref: ast::NameRef, scopes: &'a FnScopes) -> Option<&'a ScopeEntry> {
-    use std::collections::HashSet;
+    use rustc_hash::FxHashSet;
 
-    let mut shadowed = HashSet::new();
+    let mut shadowed = FxHashSet::default();
     let ret = scopes.scope_chain(name_ref.syntax())
         .flat_map(|scope| scopes.entries(scope).iter())
         .filter(|entry| shadowed.insert(entry.name()))
index 32463e499f32f4c864a6f98db131687f5adb5881..1fe6b2ebe60349876ee2800aa39d215300d387f8 100644 (file)
@@ -21,6 +21,7 @@ im = "12.0.0"
 cargo_metadata = "0.6.0"
 text_unit = { version = "0.1.2", features = ["serde"] }
 smol_str = { version = "0.1.5", features = ["serde"] }
+rustc-hash = "1.0"
 
 ra_syntax = { path = "../ra_syntax" }
 ra_editor = { path = "../ra_editor" }
index d2f76972fd199e3d36f1bdd035d37095efe123fa..60652d55eee4f57bc26d54434027564b755f1bdd 100644 (file)
@@ -16,6 +16,7 @@
 extern crate im;
 extern crate relative_path;
 extern crate cargo_metadata;
+extern crate rustc_hash;
 
 extern crate gen_lsp_server;
 extern crate ra_editor;
index 725036cc78e3ed355c9173544e42dffd6b3ae7f8..ab8be15e98b1e83914ffef14e3649fee06cf4148 100644 (file)
@@ -1,4 +1,4 @@
-use std::collections::{HashMap};
+use rustc_hash::FxHashMap;
 
 use languageserver_types::{
     Diagnostic, DiagnosticSeverity, DocumentSymbol,
@@ -267,7 +267,7 @@ pub fn handle_runnables(
             bin: "cargo".to_string(),
             args,
             env: {
-                let mut m = HashMap::new();
+                let mut m = FxHashMap::default();
                 m.insert(
                     "RUST_BACKTRACE".to_string(),
                     "short".to_string(),
index 53c6f1dffa6ab03d218b0ac588600f6a4a3008b6..402615e42583f59eaa4b28432a5bba75b7e80427 100644 (file)
@@ -3,7 +3,6 @@
 
 use std::{
     path::PathBuf,
-    collections::{HashMap},
 };
 
 use serde::{Serialize, de::DeserializeOwned};
@@ -15,6 +14,7 @@
     RawRequest, RawNotification, RawMessage, RawResponse, ErrorCode,
     handle_shutdown,
 };
+use rustc_hash::FxHashMap;
 
 use {
     req,
@@ -50,7 +50,7 @@ pub fn main_loop(
     info!("server initialized, serving requests");
     let mut state = ServerWorldState::new();
 
-    let mut pending_requests = HashMap::new();
+    let mut pending_requests = FxHashMap::default();
     let mut subs = Subscriptions::new();
     let main_res = main_loop_inner(
         internal_mode,
@@ -95,7 +95,7 @@ fn main_loop_inner(
     fs_worker: Worker<PathBuf, (PathBuf, Vec<FileEvent>)>,
     ws_worker: Worker<PathBuf, Result<CargoWorkspace>>,
     state: &mut ServerWorldState,
-    pending_requests: &mut HashMap<u64, JobHandle>,
+    pending_requests: &mut FxHashMap<u64, JobHandle>,
     subs: &mut Subscriptions,
 ) -> Result<()> {
     let (libdata_sender, libdata_receiver) = unbounded();
@@ -213,7 +213,7 @@ enum Event {
 fn on_task(
     task: Task,
     msg_sender: &Sender<RawMessage>,
-    pending_requests: &mut HashMap<u64, JobHandle>,
+    pending_requests: &mut FxHashMap<u64, JobHandle>,
 ) {
     match task {
         Task::Respond(response) => {
@@ -229,7 +229,7 @@ fn on_task(
 
 fn on_request(
     world: &mut ServerWorldState,
-    pending_requests: &mut HashMap<u64, JobHandle>,
+    pending_requests: &mut FxHashMap<u64, JobHandle>,
     pool: &ThreadPool,
     sender: &Sender<Task>,
     req: RawRequest,
@@ -269,7 +269,7 @@ fn on_request(
 fn on_notification(
     msg_sender: &Sender<RawMessage>,
     state: &mut ServerWorldState,
-    pending_requests: &mut HashMap<u64, JobHandle>,
+    pending_requests: &mut FxHashMap<u64, JobHandle>,
     subs: &mut Subscriptions,
     not: RawNotification,
 ) -> Result<()> {
index 27f92cc9a687c0abb58f1a1743f05c37cc5a796f..31015338287f7545ecce88325542d36fe25b2a37 100644 (file)
@@ -1,13 +1,13 @@
-use std::collections::HashSet;
+use rustc_hash::FxHashSet;
 use ra_analysis::FileId;
 
 pub struct Subscriptions {
-    subs: HashSet<FileId>,
+    subs: FxHashSet<FileId>,
 }
 
 impl Subscriptions {
     pub fn new() -> Subscriptions {
-        Subscriptions { subs: HashSet::new() }
+        Subscriptions { subs: FxHashSet::default() }
     }
     pub fn add_sub(&mut self, file_id: FileId) {
         self.subs.insert(file_id);
index 5db34e3e5822832a2d39139d73f137f463ab813a..43e4fd6542b3748afba0cab76ee530143a3a9827 100644 (file)
@@ -1,7 +1,7 @@
 use std::{
-    collections::{HashMap, HashSet},
     path::{Path, PathBuf},
 };
+use rustc_hash::{FxHashMap, FxHashSet};
 use cargo_metadata::{metadata_run, CargoOpt};
 use ra_syntax::SmolStr;
 
@@ -80,11 +80,11 @@ pub fn from_cargo_metadata(path: &Path) -> Result<CargoWorkspace> {
             true,
             Some(CargoOpt::AllFeatures)
         ).map_err(|e| format_err!("cargo metadata failed: {}", e))?;
-        let mut pkg_by_id = HashMap::new();
+        let mut pkg_by_id = FxHashMap::default();
         let mut packages = Vec::new();
         let mut targets = Vec::new();
 
-        let ws_members: HashSet<String> = meta.workspace_members
+        let ws_members: FxHashSet<String> = meta.workspace_members
             .into_iter()
             .map(|it| it.raw)
             .collect();
index 458c79ea9c1772e47fefa30d7331354ae9b18bc6..f80957589715b8cf00fbeb22701ced58b0a6ef68 100644 (file)
@@ -1,4 +1,4 @@
-use std::collections::HashMap;
+use rustc_hash::FxHashMap;
 use languageserver_types::{TextDocumentIdentifier, Range, Url, Position, Location};
 use url_serde;
 
@@ -149,7 +149,7 @@ pub struct Runnable {
     pub label: String,
     pub bin: String,
     pub args: Vec<String>,
-    pub env: HashMap<String, String>,
+    pub env: FxHashMap<String, String>,
 }
 
 #[derive(Serialize, Debug)]
index 865f7c4917f098e4e1f2177d2fc63781d6625034..c4cdf83d47223b281cd77461eb95e5a3950c342b 100644 (file)
@@ -1,10 +1,10 @@
 use std::{
     fs,
     path::{PathBuf, Path},
-    collections::HashMap,
     sync::Arc,
 };
 
+use rustc_hash::FxHashMap;
 use languageserver_types::Url;
 use ra_analysis::{FileId, AnalysisHost, Analysis, CrateGraph, CrateId, LibraryData, FileResolver};
 
@@ -20,7 +20,7 @@ pub struct ServerWorldState {
     pub workspaces: Arc<Vec<CargoWorkspace>>,
     pub analysis_host: AnalysisHost,
     pub path_map: PathMap,
-    pub mem_map: HashMap<FileId, Option<String>>,
+    pub mem_map: FxHashMap<FileId, Option<String>>,
 }
 
 #[derive(Clone)]
@@ -36,7 +36,7 @@ pub fn new() -> ServerWorldState {
             workspaces: Arc::new(Vec::new()),
             analysis_host: AnalysisHost::new(),
             path_map: PathMap::new(),
-            mem_map: HashMap::new(),
+            mem_map: FxHashMap::default(),
         }
     }
     pub fn apply_fs_changes(&mut self, events: Vec<FileEvent>) {
@@ -121,7 +121,7 @@ pub fn remove_mem_file(&mut self, path: &Path) -> Result<FileId> {
         Ok(file_id)
     }
     pub fn set_workspaces(&mut self, ws: Vec<CargoWorkspace>) {
-        let mut crate_roots = HashMap::new();
+        let mut crate_roots = FxHashMap::default();
         ws.iter()
           .flat_map(|ws| {
               ws.packages()