diff --git a/Cargo.toml b/Cargo.toml index 28728773..2b1c3682 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ include = ["/src/**/*.rs", "/*.toml", "/LICENSE", "/README.md"] serde = { version = "1", features = ["derive"] } serde_json = "1" dyn-clone = "1" -hashbrown = "0.12" +rustc-hash = "1" once_cell = "1" parking_lot = "0.12" dashmap = "5" diff --git a/src/cached_source.rs b/src/cached_source.rs index 3b2cdaac..321c4774 100644 --- a/src/cached_source.rs +++ b/src/cached_source.rs @@ -1,8 +1,12 @@ -use std::{borrow::Cow, hash::Hash, sync::Arc}; +use std::{ + borrow::Cow, + hash::{BuildHasherDefault, Hash}, + sync::Arc, +}; use dashmap::DashMap; -use hashbrown::hash_map::DefaultHashBuilder; use once_cell::sync::OnceCell; +use rustc_hash::FxHasher; use crate::{helpers::StreamChunks, MapOptions, Source, SourceMap}; @@ -44,7 +48,8 @@ pub struct CachedSource { inner: Arc, cached_buffer: OnceCell>, cached_source: OnceCell>, - cached_maps: DashMap, DefaultHashBuilder>, + cached_maps: + DashMap, BuildHasherDefault>, } impl CachedSource { diff --git a/src/concat_source.rs b/src/concat_source.rs index fce4b885..930f0372 100644 --- a/src/concat_source.rs +++ b/src/concat_source.rs @@ -4,7 +4,7 @@ use std::{ hash::{Hash, Hasher}, }; -use hashbrown::HashMap; +use rustc_hash::FxHashMap as HashMap; use crate::{ helpers::{get_map, GeneratedInfo, OnChunk, OnName, OnSource, StreamChunks}, @@ -138,14 +138,14 @@ impl StreamChunks for ConcatSource { } let mut current_line_offset = 0; let mut current_column_offset = 0; - let mut source_mapping: HashMap = HashMap::new(); - let mut name_mapping: HashMap = HashMap::new(); + let mut source_mapping: HashMap = HashMap::default(); + let mut name_mapping: HashMap = HashMap::default(); let mut need_to_cloas_mapping = false; for item in &self.children { let source_index_mapping: RefCell> = - RefCell::new(HashMap::new()); + RefCell::new(HashMap::default()); let name_index_mapping: RefCell> = - RefCell::new(HashMap::new()); + RefCell::new(HashMap::default()); let mut last_mapping_line = 0; let GeneratedInfo { generated_line, diff --git a/src/helpers.rs b/src/helpers.rs index 965b046b..51dbd111 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -1,6 +1,6 @@ use std::{borrow::BorrowMut, cell::RefCell, sync::Arc}; -use hashbrown::HashMap; +use rustc_hash::FxHashMap as HashMap; use substring::Substring; use crate::{ @@ -899,29 +899,29 @@ pub fn stream_chunks_of_combined_source_map( let inner_source: RefCell> = RefCell::new(inner_source.map(Into::into)); let source_mapping: RefCell> = - RefCell::new(HashMap::new()); - let mut name_mapping: HashMap = HashMap::new(); + RefCell::new(HashMap::default()); + let mut name_mapping: HashMap = HashMap::default(); let source_index_mapping: RefCell> = - RefCell::new(HashMap::new()); + RefCell::new(HashMap::default()); let name_index_mapping: RefCell> = - RefCell::new(HashMap::new()); + RefCell::new(HashMap::default()); let name_index_value_mapping: RefCell> = - RefCell::new(HashMap::new()); + RefCell::new(HashMap::default()); let inner_source_index: RefCell = RefCell::new(-2); let inner_source_index_mapping: RefCell> = - RefCell::new(HashMap::new()); + RefCell::new(HashMap::default()); let inner_source_index_value_mapping: RefCell< HashMap)>, - > = RefCell::new(HashMap::new()); + > = RefCell::new(HashMap::default()); let inner_source_contents: RefCell>> = - RefCell::new(HashMap::new()); + RefCell::new(HashMap::default()); let inner_source_content_lines: RefCell< HashMap>>>, - > = RefCell::new(HashMap::new()); + > = RefCell::new(HashMap::default()); let inner_name_index_mapping: RefCell> = - RefCell::new(HashMap::new()); + RefCell::new(HashMap::default()); let inner_name_index_value_mapping: RefCell> = - RefCell::new(HashMap::new()); + RefCell::new(HashMap::default()); let inner_source_map_line_data: RefCell> = RefCell::new(Vec::new()); let find_inner_mapping = |line: i64, column: i64| -> Option { diff --git a/src/replace_source.rs b/src/replace_source.rs index fb53d745..633f951e 100644 --- a/src/replace_source.rs +++ b/src/replace_source.rs @@ -5,8 +5,8 @@ use std::{ sync::Arc, }; -use hashbrown::HashMap; use parking_lot::Mutex; +use rustc_hash::FxHashMap as HashMap; use substring::Substring; use crate::{ @@ -169,9 +169,9 @@ impl StreamChunks for ReplaceSource { let source_content_lines: RefCell>>> = RefCell::new(Vec::new()); let name_mapping: RefCell> = - RefCell::new(HashMap::new()); + RefCell::new(HashMap::default()); let name_index_mapping: RefCell> = - RefCell::new(HashMap::new()); + RefCell::new(HashMap::default()); // check if source_content[line][col] is equal to expect // Why this is needed?