Skip to content

Commit

Permalink
chore: add and use foldhash
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Dec 8, 2024
1 parent 76309d7 commit 6df5271
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 51 deletions.
96 changes: 58 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ derive_builder = "0.20.2"
derive_more = { version = "1.0", features = ["full"] }
match_cfg = "0.1"
strum = "0.26"
thiserror = "1.0"
thiserror = ">=1.0"

# parallel
parking_lot = "0.12"
Expand All @@ -150,6 +150,7 @@ cfg-if = "1.0"
const_format = "0.2"
dashmap = "6.0"
either = "1"
foldhash = "0.1.3"
hex = { package = "const-hex", version = "1.10" }
index_vec = "0.1.3"
indexmap = "2.2"
Expand Down
1 change: 1 addition & 0 deletions crates/data-structures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ indexmap.workspace = true
parking_lot.workspace = true
rayon.workspace = true
rustc-hash.workspace = true
foldhash.workspace = true
smallvec.workspace = true

[features]
Expand Down
13 changes: 5 additions & 8 deletions crates/data-structures/src/map.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
//! Map types.
use indexmap::{IndexMap, IndexSet};
use std::{
collections::{HashMap, HashSet},
hash::BuildHasherDefault,
};
use std::collections::{HashMap, HashSet};

pub use rustc_hash::{self, FxBuildHasher, FxHasher};

Expand All @@ -14,10 +11,10 @@ pub type StdEntry<'a, K, V> = std::collections::hash_map::Entry<'a, K, V>;
pub type IndexEntry<'a, K, V> = indexmap::map::Entry<'a, K, V>;

/// A [`HashMap`] using [`FxHasher`] as its hasher.
pub type FxHashMap<K, V> = HashMap<K, V, BuildHasherDefault<FxHasher>>;
pub type FxHashMap<K, V> = HashMap<K, V, FxBuildHasher>;
/// A [`HashSet`] using [`FxHasher`] as its hasher.
pub type FxHashSet<V> = HashSet<V, BuildHasherDefault<FxHasher>>;
pub type FxHashSet<V> = HashSet<V, FxBuildHasher>;
/// An [`IndexMap`] using [`FxHasher`] as its hasher.
pub type FxIndexMap<K, V> = IndexMap<K, V, BuildHasherDefault<FxHasher>>;
pub type FxIndexMap<K, V> = IndexMap<K, V, FxBuildHasher>;
/// An [`IndexSet`] using [`FxHasher`] as its hasher.
pub type FxIndexSet<V> = IndexSet<V, BuildHasherDefault<FxHasher>>;
pub type FxIndexSet<V> = IndexSet<V, FxBuildHasher>;
2 changes: 1 addition & 1 deletion crates/interface/src/source_map/file_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub enum ResolveError {
ReadFile(PathBuf, #[source] io::Error),
#[error("file {0} not found")]
NotFound(PathBuf),
#[error("multiple files match {0}: {}", _1.iter().map(|f| f.name.display()).format(", "))]
#[error("multiple files match {}: {}", .0.display(), .1.iter().map(|f| f.name.display()).format(", "))]
MultipleMatches(PathBuf, Vec<Arc<SourceFile>>),
}

Expand Down
6 changes: 3 additions & 3 deletions crates/interface/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,12 +417,12 @@ impl LassoInterner {
unsafe impl lasso::Key for Symbol {
#[inline]
fn into_usize(self) -> usize {
self.as_u32() as usize
self.0.index()
}

#[inline]
fn try_from_usize(int: usize) -> Option<Self> {
int.try_into().ok().map(Self::new)
fn try_from_usize(value: usize) -> Option<Self> {
BaseIndex32::try_from_usize(value).map(Self)
}
}

Expand Down

0 comments on commit 6df5271

Please sign in to comment.