mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-29 03:02:55 +00:00
Use FxHasher in resolver (#3641)
## Summary We can use `FxHasher` in a few more places for string and version keys. This gives a consistent ~2% improvement to warm resolves.
This commit is contained in:
parent
39af09f09b
commit
0f67a6ceea
5 changed files with 51 additions and 30 deletions
|
|
@ -1,5 +1,5 @@
|
|||
use std::borrow::Borrow;
|
||||
use std::hash::Hash;
|
||||
use std::hash::{BuildHasher, Hash, RandomState};
|
||||
use std::sync::Arc;
|
||||
|
||||
use dashmap::DashMap;
|
||||
|
|
@ -14,11 +14,11 @@ use tokio::sync::Notify;
|
|||
///
|
||||
/// Note that this always clones the value out of the underlying map. Because
|
||||
/// of this, it's common to wrap the `V` in an `Arc<V>` to make cloning cheap.
|
||||
pub struct OnceMap<K, V> {
|
||||
items: DashMap<K, Value<V>>,
|
||||
pub struct OnceMap<K, V, H = RandomState> {
|
||||
items: DashMap<K, Value<V>, H>,
|
||||
}
|
||||
|
||||
impl<K: Eq + Hash, V: Clone> OnceMap<K, V> {
|
||||
impl<K: Eq + Hash, V: Clone, H: BuildHasher + Clone> OnceMap<K, V, H> {
|
||||
/// Register that you want to start a job.
|
||||
///
|
||||
/// If this method returns `true`, you need to start a job and call [`OnceMap::done`] eventually
|
||||
|
|
@ -97,10 +97,10 @@ impl<K: Eq + Hash, V: Clone> OnceMap<K, V> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<K: Eq + Hash + Clone, V> Default for OnceMap<K, V> {
|
||||
impl<K: Eq + Hash + Clone, V, H: Default + BuildHasher + Clone> Default for OnceMap<K, V, H> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
items: DashMap::new(),
|
||||
items: DashMap::with_hasher(H::default()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue