From dc2b30e9b6084048e441765b91ef830a836d3dfc Mon Sep 17 00:00:00 2001 From: Muhammad Mominul Huque Date: Fri, 12 Oct 2018 00:07:44 +0600 Subject: Replace HashMap, HashSet with FxHashMap and FxHashSet --- crates/ra_lsp_server/src/main_loop/handlers.rs | 4 ++-- crates/ra_lsp_server/src/main_loop/mod.rs | 12 ++++++------ crates/ra_lsp_server/src/main_loop/subscriptions.rs | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'crates/ra_lsp_server/src/main_loop') diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 725036cc7..ab8be15e9 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -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(), diff --git a/crates/ra_lsp_server/src/main_loop/mod.rs b/crates/ra_lsp_server/src/main_loop/mod.rs index 53c6f1dff..402615e42 100644 --- a/crates/ra_lsp_server/src/main_loop/mod.rs +++ b/crates/ra_lsp_server/src/main_loop/mod.rs @@ -3,7 +3,6 @@ mod subscriptions; use std::{ path::PathBuf, - collections::{HashMap}, }; use serde::{Serialize, de::DeserializeOwned}; @@ -15,6 +14,7 @@ use gen_lsp_server::{ 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)>, ws_worker: Worker>, state: &mut ServerWorldState, - pending_requests: &mut HashMap, + pending_requests: &mut FxHashMap, subs: &mut Subscriptions, ) -> Result<()> { let (libdata_sender, libdata_receiver) = unbounded(); @@ -213,7 +213,7 @@ fn main_loop_inner( fn on_task( task: Task, msg_sender: &Sender, - pending_requests: &mut HashMap, + pending_requests: &mut FxHashMap, ) { match task { Task::Respond(response) => { @@ -229,7 +229,7 @@ fn on_task( fn on_request( world: &mut ServerWorldState, - pending_requests: &mut HashMap, + pending_requests: &mut FxHashMap, pool: &ThreadPool, sender: &Sender, req: RawRequest, @@ -269,7 +269,7 @@ fn on_request( fn on_notification( msg_sender: &Sender, state: &mut ServerWorldState, - pending_requests: &mut HashMap, + pending_requests: &mut FxHashMap, subs: &mut Subscriptions, not: RawNotification, ) -> Result<()> { diff --git a/crates/ra_lsp_server/src/main_loop/subscriptions.rs b/crates/ra_lsp_server/src/main_loop/subscriptions.rs index 27f92cc9a..310153382 100644 --- a/crates/ra_lsp_server/src/main_loop/subscriptions.rs +++ b/crates/ra_lsp_server/src/main_loop/subscriptions.rs @@ -1,13 +1,13 @@ -use std::collections::HashSet; +use rustc_hash::FxHashSet; use ra_analysis::FileId; pub struct Subscriptions { - subs: HashSet, + subs: FxHashSet, } 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); -- cgit v1.2.3