Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate twox-hash -> xxhash-rust. Switch to Xxh3 for better performance. #2080

Merged
merged 3 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]
Loading