-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
use ahash::AHasher; | ||
use std::hash::BuildHasherDefault; | ||
use foldhash::fast::FixedState; | ||
|
||
/// DOS attacks aren't a concern for Rustlings. Therefore, we use `ahash` with fixed seeds. | ||
pub type HashSet<T> = std::collections::HashSet<T, BuildHasherDefault<AHasher>>; | ||
/// DOS attacks aren't a concern for Rustlings. Therefore, we use `foldhash` with a fixed state. | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
mo8it
Author
Contributor
|
||
pub type HashSet<T> = std::collections::HashSet<T, FixedState>; | ||
|
||
#[inline] | ||
pub fn hash_set_with_capacity<T>(capacity: usize) -> HashSet<T> { | ||
HashSet::with_capacity_and_hasher(capacity, BuildHasherDefault::<AHasher>::default()) | ||
HashSet::with_capacity_and_hasher(capacity, FixedState::default()) | ||
} |
Why even bother with a non-default hash? It seems to only be used to track exercises and paths, i.e. very few unless someone is trying to hack the system, and I/O should be the limiting factor anyway.