Skip to content

Commit

Permalink
switch from rustc-hash to foldhash
Browse files Browse the repository at this point in the history
  • Loading branch information
niklak committed Oct 27, 2024
1 parent c8b815e commit 7e104b6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ jobs:
with:
tool: wasm-bindgen-cli
- name: Run tests
run: cargo test --target wasm32-unknown-unknown --all
run: cargo test --target wasm32-unknown-unknown --all
- name: Run tests with hashbrown
run: cargo test --target wasm32-unknown-unknown --features "hashbrown"
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ All notable changes to the `dom_query` crate will be documented in this file.
- Internal changes due to switch to `selectors` v0.26.0 switch.
- `Selection` methods that required `&mut` now doesn't require `&mut`, finally.
- Improve performance for `Document::from`, `Selection::select` and others.
- Switched from using `rustc-hash` to `foldhash`.

### Added
- Added `Node::ancestors` method, that allows to get all or limited number of ancestors of a node.
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ html5ever = "0.29.0"
selectors = "0.26.0"
cssparser = "0.34.0"
tendril = "0.4.3"
rustc-hash = "2.0.0"
hashbrown = {version = "0.15.0", default-features = false, features = ["allocator-api2", "inline-more"], optional = true}
foldhash = "0.1.3"
hashbrown = {version = "0.15.0", default-features = false, features = ["allocator-api2", "inline-more", "default-hasher"], optional = true}
precomputed-hash = "0.1.1"

[dev-dependencies]
Expand Down
12 changes: 5 additions & 7 deletions src/entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
#[cfg(feature = "hashbrown")]
mod inline {
use hashbrown::HashSet;
use rustc_hash::FxHasher;
use std::hash::BuildHasherDefault;
pub type NodeIdSet = HashSet<crate::NodeId, BuildHasherDefault<FxHasher>>;
pub type HashSetFx<K> = HashSet<K, BuildHasherDefault<FxHasher>>;
pub type NodeIdSet = HashSet<crate::NodeId>;
pub type HashSetFx<K> = HashSet<K>;
}

#[cfg(not(feature = "hashbrown"))]
mod inline {
use rustc_hash::FxHashSet;
pub type NodeIdSet = FxHashSet<crate::NodeId>;
pub type HashSetFx<K> = FxHashSet<K>;
use foldhash::HashSet;
pub type NodeIdSet = HashSet<crate::NodeId>;
pub type HashSetFx<K> = HashSet<K>;
}

pub(crate) use inline::{HashSetFx, NodeIdSet};

0 comments on commit 7e104b6

Please sign in to comment.