Skip to content

Commit

Permalink
Merge pull request #2080 from dtzxporter/xxhash-3-speed
Browse files Browse the repository at this point in the history
Migrate twox-hash -> xxhash-rust. Switch to Xxh3 for better performance.
  • Loading branch information
hecrj committed Nov 11, 2023
2 parents 751ea77 + 107e842 commit 53f5f93
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ thiserror = "1.0"
tiny-skia = "0.10"
tokio = "1.0"
tracing = "0.1"
twox-hash = { version = "1.0", default-features = false }
xxhash-rust = { version = "0.8", features = ["xxh3"] }
unicode-segmentation = "1.0"
wasm-bindgen-futures = "0.4"
wasm-timer = "0.2"
Expand Down
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ keywords.workspace = true
bitflags.workspace = true
log.workspace = true
thiserror.workspace = true
twox-hash.workspace = true
xxhash-rust.workspace = true
num-traits.workspace = true

palette.workspace = true
Expand Down
5 changes: 3 additions & 2 deletions core/src/hasher.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// The hasher used to compare layouts.
#[derive(Debug, Default)]
pub struct Hasher(twox_hash::XxHash64);
#[allow(missing_debug_implementations)] // Doesn't really make sense to have debug on the hasher state anyways.
#[derive(Default)]
pub struct Hasher(xxhash_rust::xxh3::Xxh3);

impl core::hash::Hasher for Hasher {
fn write(&mut self, bytes: &[u8]) {
Expand Down
6 changes: 1 addition & 5 deletions graphics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ once_cell.workspace = true
raw-window-handle.workspace = true
rustc-hash.workspace = true
thiserror.workspace = true
twox-hash.workspace = true
unicode-segmentation.workspace = true
xxhash-rust.workspace = true

image.workspace = true
image.optional = true
Expand All @@ -44,7 +44,3 @@ kamadak-exif.optional = true

lyon_path.workspace = true
lyon_path.optional = true

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
twox-hash.workspace = true
twox-hash.features = ["std"]
6 changes: 1 addition & 5 deletions graphics/src/text/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ pub struct Cache {
hasher: HashBuilder,
}

#[cfg(not(target_arch = "wasm32"))]
type HashBuilder = twox_hash::RandomXxHashBuilder64;

#[cfg(target_arch = "wasm32")]
type HashBuilder = std::hash::BuildHasherDefault<twox_hash::XxHash64>;
type HashBuilder = xxhash_rust::xxh3::Xxh3Builder;

impl Cache {
/// Creates a new empty [`Cache`].
Expand Down
6 changes: 1 addition & 5 deletions tiny_skia/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ raw-window-handle.workspace = true
rustc-hash.workspace = true
softbuffer.workspace = true
tiny-skia.workspace = true
twox-hash.workspace = true
xxhash-rust.workspace = true

resvg.workspace = true
resvg.optional = true

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
twox-hash.workspace = true
twox-hash.features = ["std"]

0 comments on commit 53f5f93

Please sign in to comment.