diff --git a/Cargo.lock b/Cargo.lock index 2137dae78c19e..5e0c19e4c6cb3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -564,6 +564,7 @@ dependencies = [ name = "auto-hash-map" version = "0.1.0" dependencies = [ + "rustc-hash", "serde", "smallvec", ] diff --git a/turbopack/crates/turbo-tasks-auto-hash-map/Cargo.toml b/turbopack/crates/turbo-tasks-auto-hash-map/Cargo.toml index 0c2d4a8579ae5..e81d8cecbee44 100644 --- a/turbopack/crates/turbo-tasks-auto-hash-map/Cargo.toml +++ b/turbopack/crates/turbo-tasks-auto-hash-map/Cargo.toml @@ -9,5 +9,6 @@ edition = "2021" workspace = true [dependencies] +rustc-hash = { workspace = true } serde = { workspace = true, features = ["derive"] } smallvec = { workspace = true } diff --git a/turbopack/crates/turbo-tasks-auto-hash-map/src/map.rs b/turbopack/crates/turbo-tasks-auto-hash-map/src/map.rs index 5285285fcea17..3e1c604b3fee1 100644 --- a/turbopack/crates/turbo-tasks-auto-hash-map/src/map.rs +++ b/turbopack/crates/turbo-tasks-auto-hash-map/src/map.rs @@ -1,11 +1,12 @@ use std::{ borrow::Borrow, - collections::{hash_map::RandomState, HashMap}, + collections::HashMap, fmt::{Debug, Formatter}, - hash::{BuildHasher, Hash}, + hash::{BuildHasher, BuildHasherDefault, Hash}, marker::PhantomData, }; +use rustc_hash::FxHasher; use serde::{ de::{MapAccess, Visitor}, ser::SerializeMap, @@ -16,7 +17,7 @@ use smallvec::SmallVec; use crate::{MAX_LIST_SIZE, MIN_HASH_SIZE}; #[derive(Clone)] -pub enum AutoMap { +pub enum AutoMap, const I: usize = 0> { List(SmallVec<[(K, V); I]>), Map(Box>), } @@ -33,7 +34,7 @@ impl Debug for AutoMap { } } -impl AutoMap { +impl AutoMap, 0> { /// see [HashMap::new](https://doc.rust-lang.org/std/collections/struct.HashMap.html#method.new) pub const fn new() -> Self { AutoMap::List(SmallVec::new_const()) diff --git a/turbopack/crates/turbo-tasks-auto-hash-map/src/set.rs b/turbopack/crates/turbo-tasks-auto-hash-map/src/set.rs index a211d8eb3d2b9..3a74b55044e43 100644 --- a/turbopack/crates/turbo-tasks-auto-hash-map/src/set.rs +++ b/turbopack/crates/turbo-tasks-auto-hash-map/src/set.rs @@ -1,16 +1,16 @@ use std::{ - collections::hash_map::RandomState, fmt::Debug, - hash::{BuildHasher, Hash}, + hash::{BuildHasher, BuildHasherDefault, Hash}, marker::PhantomData, }; +use rustc_hash::FxHasher; use serde::{Deserialize, Serialize}; use crate::AutoMap; #[derive(Clone)] -pub struct AutoSet { +pub struct AutoSet, const I: usize = 0> { map: AutoMap, } @@ -28,7 +28,7 @@ impl Debug for AutoSet { } } -impl AutoSet { +impl AutoSet, 0> { /// see [HashSet::new](https://doc.rust-lang.org/std/collections/hash_set/struct.HashSet.html#method.new) pub const fn new() -> Self { Self { diff --git a/turbopack/crates/turbo-tasks-memory/src/count_hash_set.rs b/turbopack/crates/turbo-tasks-memory/src/count_hash_set.rs index 06f3ef1c94aa2..a860b0b94bf1f 100644 --- a/turbopack/crates/turbo-tasks-memory/src/count_hash_set.rs +++ b/turbopack/crates/turbo-tasks-memory/src/count_hash_set.rs @@ -1,8 +1,7 @@ use std::{ borrow::Borrow, - collections::hash_map::RandomState, fmt::{Debug, Formatter}, - hash::{BuildHasher, Hash}, + hash::{BuildHasher, BuildHasherDefault, Hash}, iter::FilterMap, }; @@ -10,9 +9,10 @@ use auto_hash_map::{ map::{Entry, Iter, RawEntry}, AutoMap, }; +use rustc_hash::FxHasher; #[derive(Clone)] -pub struct CountHashSet { +pub struct CountHashSet> { inner: AutoMap, negative_entries: usize, }