From fe0980cbe8423ae757e87265eda4e2537cccdf31 Mon Sep 17 00:00:00 2001 From: Rom Grk Date: Tue, 20 Aug 2024 22:17:58 -0400 Subject: [PATCH 01/10] feat: add rust implementation --- packages/hash/murmur-rust/.gitignore | 6 ++ packages/hash/murmur-rust/Cargo.toml | 27 +++++++++ packages/hash/murmur-rust/README.md | 84 ++++++++++++++++++++++++++++ packages/hash/murmur-rust/index.js | 29 ++++++++++ packages/hash/murmur-rust/src/lib.rs | 57 +++++++++++++++++++ 5 files changed, 203 insertions(+) create mode 100644 packages/hash/murmur-rust/.gitignore create mode 100644 packages/hash/murmur-rust/Cargo.toml create mode 100644 packages/hash/murmur-rust/README.md create mode 100644 packages/hash/murmur-rust/index.js create mode 100644 packages/hash/murmur-rust/src/lib.rs diff --git a/packages/hash/murmur-rust/.gitignore b/packages/hash/murmur-rust/.gitignore new file mode 100644 index 000000000..4e301317e --- /dev/null +++ b/packages/hash/murmur-rust/.gitignore @@ -0,0 +1,6 @@ +/target +**/*.rs.bk +Cargo.lock +bin/ +pkg/ +wasm-pack.log diff --git a/packages/hash/murmur-rust/Cargo.toml b/packages/hash/murmur-rust/Cargo.toml new file mode 100644 index 000000000..3699568c3 --- /dev/null +++ b/packages/hash/murmur-rust/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "murmur" +version = "0.1.0" +authors = ["Rom Grk "] +edition = "2018" + +[lib] +crate-type = ["cdylib", "rlib"] + +[features] +default = ["console_error_panic_hook"] + +[dependencies] +wasm-bindgen = "0.2.84" + +# The `console_error_panic_hook` crate provides better debugging of panics by +# logging them with `console.error`. This is great for development, but requires +# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for +# code size when deploying. +console_error_panic_hook = { version = "0.1.7", optional = true } + +[dev-dependencies] +wasm-bindgen-test = "0.3.34" + +[profile.release] +# Tell `rustc` to optimize for small code size. +opt-level = "s" diff --git a/packages/hash/murmur-rust/README.md b/packages/hash/murmur-rust/README.md new file mode 100644 index 000000000..6b6840850 --- /dev/null +++ b/packages/hash/murmur-rust/README.md @@ -0,0 +1,84 @@ +
+ +

wasm-pack-template

+ + A template for kick starting a Rust and WebAssembly project using wasm-pack. + +

+ Build Status +

+ +

+ Tutorial + | + Chat +

+ + Built with 🦀🕸 by The Rust and WebAssembly Working Group +
+ +## About + +[**📚 Read this template tutorial! 📚**][template-docs] + +This template is designed for compiling Rust libraries into WebAssembly and +publishing the resulting package to NPM. + +Be sure to check out [other `wasm-pack` tutorials online][tutorials] for other +templates and usages of `wasm-pack`. + +[tutorials]: https://rustwasm.github.io/docs/wasm-pack/tutorials/index.html +[template-docs]: https://rustwasm.github.io/docs/wasm-pack/tutorials/npm-browser-packages/index.html + +## 🚴 Usage + +### 🐑 Use `cargo generate` to Clone this Template + +[Learn more about `cargo generate` here.](https://github.com/ashleygwilliams/cargo-generate) + +``` +cargo generate --git https://github.com/rustwasm/wasm-pack-template.git --name my-project +cd my-project +``` + +### 🛠️ Build with `wasm-pack build` + +``` +wasm-pack build +``` + +### 🔬 Test in Headless Browsers with `wasm-pack test` + +``` +wasm-pack test --headless --firefox +``` + +### 🎁 Publish to NPM with `wasm-pack publish` + +``` +wasm-pack publish +``` + +## 🔋 Batteries Included + +* [`wasm-bindgen`](https://github.com/rustwasm/wasm-bindgen) for communicating + between WebAssembly and JavaScript. +* [`console_error_panic_hook`](https://github.com/rustwasm/console_error_panic_hook) + for logging panic messages to the developer console. +* `LICENSE-APACHE` and `LICENSE-MIT`: most Rust projects are licensed this way, so these are included for you + +## License + +Licensed under either of + +* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally +submitted for inclusion in the work by you, as defined in the Apache-2.0 +license, shall be dual licensed as above, without any additional terms or +conditions. diff --git a/packages/hash/murmur-rust/index.js b/packages/hash/murmur-rust/index.js new file mode 100644 index 000000000..63683bfea --- /dev/null +++ b/packages/hash/murmur-rust/index.js @@ -0,0 +1,29 @@ +let imports = {}; +let wasm; + +const path = require('path').join(__dirname, './pkg/murmur_bg.wasm'); +const bytes = require('fs').readFileSync(path); + +const wasmModule = new WebAssembly.Module(bytes); +const wasmInstance = new WebAssembly.Instance(wasmModule, imports); +wasm = wasmInstance.exports; +module.exports.__wasm = wasm; + + +// Manually written to encode faster than wasm_bindgen does. + +let MEM_START = 32 // Alignement for the bytes slice + +let memory = null; +let cachedTextEncoder = new TextEncoder('utf-8'); + +module.exports.murmur2 = function(input) { + const result = cachedTextEncoder.encodeInto(input, memory); + + const ptr0 = MEM_START; + const len0 = result.written; + + const ret = wasm.murmur2(ptr0, len0); + return ret >>> 0; +}; +memory = new Uint8Array(wasm.memory.buffer).subarray(MEM_START); diff --git a/packages/hash/murmur-rust/src/lib.rs b/packages/hash/murmur-rust/src/lib.rs new file mode 100644 index 000000000..b3c1aff8e --- /dev/null +++ b/packages/hash/murmur-rust/src/lib.rs @@ -0,0 +1,57 @@ +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + #[wasm_bindgen(js_namespace = console)] + fn log(s: &str); + + #[wasm_bindgen(js_namespace = console, js_name = log)] + fn log_u32(a: u32); +} + + +const M: u32 = 0x5bd1e995; +const R: u32 = 24; + + +#[wasm_bindgen] +pub fn murmur2(bytes: *const u8, mut length: usize) -> u32 { + let data = unsafe { std::slice::from_raw_parts( + std::mem::transmute::<_, *const u32>(bytes), + length, // so wrong but doesnt matter + ) }; + + let mut h = 0; // Not initialized to match emotion's implementation + let mut i = 0; + + while length >= 4 { + let mut k = unsafe { *data.get_unchecked(i) }; + + k *= M; + k ^= k >> R; + k *= M; + + h *= M; + h ^= k; + + i += 1; + length -= 4; + } + + if length >= 3 { + h ^= (unsafe { *bytes.add(i + 2) as u32 } & 0xff) << 16; + } + if length >= 2 { + h ^= (unsafe { *bytes.add(i + 1) as u32 } & 0xff) << 8; + } + if length >= 1 { + h ^= (unsafe { *bytes.add(i + 0) as u32 } & 0xff); + h = (h & 0xffff) * M + (((h >> 16) * 0xe995) << 16); + } + + h ^= h >> 13; + h = (h & 0xffff) * M + (((h >> 16) * 0xe995) << 16); + h = h ^ (h >> 15); + + return h; +} From c882f33fc94bf47607d7b6524cf61476b0f73bd9 Mon Sep 17 00:00:00 2001 From: Rom Grk Date: Tue, 20 Aug 2024 22:20:25 -0400 Subject: [PATCH 02/10] lint --- packages/hash/murmur-rust/Cargo.toml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/packages/hash/murmur-rust/Cargo.toml b/packages/hash/murmur-rust/Cargo.toml index 3699568c3..76b116e90 100644 --- a/packages/hash/murmur-rust/Cargo.toml +++ b/packages/hash/murmur-rust/Cargo.toml @@ -7,18 +7,9 @@ edition = "2018" [lib] crate-type = ["cdylib", "rlib"] -[features] -default = ["console_error_panic_hook"] - [dependencies] wasm-bindgen = "0.2.84" -# The `console_error_panic_hook` crate provides better debugging of panics by -# logging them with `console.error`. This is great for development, but requires -# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for -# code size when deploying. -console_error_panic_hook = { version = "0.1.7", optional = true } - [dev-dependencies] wasm-bindgen-test = "0.3.34" From bd8672e4822564547baf3e732934a8b00e444780 Mon Sep 17 00:00:00 2001 From: Rom Grk Date: Wed, 21 Aug 2024 00:14:58 -0400 Subject: [PATCH 03/10] update --- .../murmur-rust => hash-rust}/.gitignore | 0 packages/hash-rust/Cargo.toml | 30 +++++++++++++++++++ .../{hash/murmur-rust => hash-rust}/README.md | 0 .../{hash/murmur-rust => hash-rust}/index.js | 22 +++++++------- .../murmur-rust => hash-rust}/src/lib.rs | 18 +++++++---- packages/hash/murmur-rust/Cargo.toml | 18 ----------- 6 files changed, 53 insertions(+), 35 deletions(-) rename packages/{hash/murmur-rust => hash-rust}/.gitignore (100%) create mode 100644 packages/hash-rust/Cargo.toml rename packages/{hash/murmur-rust => hash-rust}/README.md (100%) rename packages/{hash/murmur-rust => hash-rust}/index.js (54%) rename packages/{hash/murmur-rust => hash-rust}/src/lib.rs (73%) delete mode 100644 packages/hash/murmur-rust/Cargo.toml diff --git a/packages/hash/murmur-rust/.gitignore b/packages/hash-rust/.gitignore similarity index 100% rename from packages/hash/murmur-rust/.gitignore rename to packages/hash-rust/.gitignore diff --git a/packages/hash-rust/Cargo.toml b/packages/hash-rust/Cargo.toml new file mode 100644 index 000000000..517b3be79 --- /dev/null +++ b/packages/hash-rust/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "murmur" +version = "0.1.0" +authors = ["Rom Grk "] +edition = "2018" + +[lib] +crate-type = ["cdylib", "rlib"] + +[dependencies] +cityhasher = "0.1.0" +wasm-bindgen = "0.2.84" + +[dependencies.xxhash-rust] +version = "0.8.12" +features = ["xxh32", "xxh3"] + +[dev-dependencies] +wasm-bindgen-test = "0.3.34" + +[package.metadata.wasm-pack.profile.dev] +wasm-opt = ['--enable-simd'] +[package.metadata.wasm-pack.profile.profiling] +wasm-opt = ['--enable-simd'] +[package.metadata.wasm-pack.profile.release] +wasm-opt = ['--enable-simd'] + +[profile.release] +# Tell `rustc` to optimize for small code size. +opt-level = "s" diff --git a/packages/hash/murmur-rust/README.md b/packages/hash-rust/README.md similarity index 100% rename from packages/hash/murmur-rust/README.md rename to packages/hash-rust/README.md diff --git a/packages/hash/murmur-rust/index.js b/packages/hash-rust/index.js similarity index 54% rename from packages/hash/murmur-rust/index.js rename to packages/hash-rust/index.js index 63683bfea..1e4508df1 100644 --- a/packages/hash/murmur-rust/index.js +++ b/packages/hash-rust/index.js @@ -3,27 +3,27 @@ let wasm; const path = require('path').join(__dirname, './pkg/murmur_bg.wasm'); const bytes = require('fs').readFileSync(path); - const wasmModule = new WebAssembly.Module(bytes); const wasmInstance = new WebAssembly.Instance(wasmModule, imports); wasm = wasmInstance.exports; -module.exports.__wasm = wasm; // Manually written to encode faster than wasm_bindgen does. let MEM_START = 32 // Alignement for the bytes slice -let memory = null; +let memory = new Uint8Array(wasm.memory.buffer).subarray(MEM_START); let cachedTextEncoder = new TextEncoder('utf-8'); -module.exports.murmur2 = function(input) { - const result = cachedTextEncoder.encodeInto(input, memory); +module.exports.xxh = wrapStringToU32('xxh'); +module.exports.murmur2 = wrapStringToU32('murmur2'); - const ptr0 = MEM_START; - const len0 = result.written; +function wrapStringToU32(name) { + return function(input) { + const ptr0 = MEM_START; + const len0 = cachedTextEncoder.encodeInto(input, memory).written; + const ret = wasm[name](ptr0, len0); + return ret; + } +} - const ret = wasm.murmur2(ptr0, len0); - return ret >>> 0; -}; -memory = new Uint8Array(wasm.memory.buffer).subarray(MEM_START); diff --git a/packages/hash/murmur-rust/src/lib.rs b/packages/hash-rust/src/lib.rs similarity index 73% rename from packages/hash/murmur-rust/src/lib.rs rename to packages/hash-rust/src/lib.rs index b3c1aff8e..04e663435 100644 --- a/packages/hash/murmur-rust/src/lib.rs +++ b/packages/hash-rust/src/lib.rs @@ -1,19 +1,25 @@ use wasm_bindgen::prelude::*; +use xxhash_rust::xxh32::xxh32; +use xxhash_rust::xxh3::xxh3_64; + +// xxh via xxhash_rust #[wasm_bindgen] -extern "C" { - #[wasm_bindgen(js_namespace = console)] - fn log(s: &str); +pub fn xxh(bytes: *const u8, length: usize) -> u32 { + let data = unsafe { std::slice::from_raw_parts( + std::mem::transmute::<_, *const u8>(bytes), + length, + ) }; - #[wasm_bindgen(js_namespace = console, js_name = log)] - fn log_u32(a: u32); + return xxh32(data, 0); } +// murmur2 implementation based on emotion's implementation (differs from original) + const M: u32 = 0x5bd1e995; const R: u32 = 24; - #[wasm_bindgen] pub fn murmur2(bytes: *const u8, mut length: usize) -> u32 { let data = unsafe { std::slice::from_raw_parts( diff --git a/packages/hash/murmur-rust/Cargo.toml b/packages/hash/murmur-rust/Cargo.toml deleted file mode 100644 index 76b116e90..000000000 --- a/packages/hash/murmur-rust/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "murmur" -version = "0.1.0" -authors = ["Rom Grk "] -edition = "2018" - -[lib] -crate-type = ["cdylib", "rlib"] - -[dependencies] -wasm-bindgen = "0.2.84" - -[dev-dependencies] -wasm-bindgen-test = "0.3.34" - -[profile.release] -# Tell `rustc` to optimize for small code size. -opt-level = "s" From b97aedafba82a02633f8fb263d749784d121ee30 Mon Sep 17 00:00:00 2001 From: Rom Grk Date: Wed, 21 Aug 2024 00:53:46 -0400 Subject: [PATCH 04/10] lint --- packages/hash-rust/README.md | 85 ++---------------------------------- 1 file changed, 3 insertions(+), 82 deletions(-) diff --git a/packages/hash-rust/README.md b/packages/hash-rust/README.md index 6b6840850..9dece3ac8 100644 --- a/packages/hash-rust/README.md +++ b/packages/hash-rust/README.md @@ -1,84 +1,5 @@ -
+# hash-rust -

wasm-pack-template

+Bootstraped from a standard `wasm-pack` template. - A template for kick starting a Rust and WebAssembly project using wasm-pack. - -

- Build Status -

- -

- Tutorial - | - Chat -

- - Built with 🦀🕸 by The Rust and WebAssembly Working Group -
- -## About - -[**📚 Read this template tutorial! 📚**][template-docs] - -This template is designed for compiling Rust libraries into WebAssembly and -publishing the resulting package to NPM. - -Be sure to check out [other `wasm-pack` tutorials online][tutorials] for other -templates and usages of `wasm-pack`. - -[tutorials]: https://rustwasm.github.io/docs/wasm-pack/tutorials/index.html -[template-docs]: https://rustwasm.github.io/docs/wasm-pack/tutorials/npm-browser-packages/index.html - -## 🚴 Usage - -### 🐑 Use `cargo generate` to Clone this Template - -[Learn more about `cargo generate` here.](https://github.com/ashleygwilliams/cargo-generate) - -``` -cargo generate --git https://github.com/rustwasm/wasm-pack-template.git --name my-project -cd my-project -``` - -### 🛠️ Build with `wasm-pack build` - -``` -wasm-pack build -``` - -### 🔬 Test in Headless Browsers with `wasm-pack test` - -``` -wasm-pack test --headless --firefox -``` - -### 🎁 Publish to NPM with `wasm-pack publish` - -``` -wasm-pack publish -``` - -## 🔋 Batteries Included - -* [`wasm-bindgen`](https://github.com/rustwasm/wasm-bindgen) for communicating - between WebAssembly and JavaScript. -* [`console_error_panic_hook`](https://github.com/rustwasm/console_error_panic_hook) - for logging panic messages to the developer console. -* `LICENSE-APACHE` and `LICENSE-MIT`: most Rust projects are licensed this way, so these are included for you - -## License - -Licensed under either of - -* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) -* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) - -at your option. - -### Contribution - -Unless you explicitly state otherwise, any contribution intentionally -submitted for inclusion in the work by you, as defined in the Apache-2.0 -license, shall be dual licensed as above, without any additional terms or -conditions. +Build with `wasm-pack build --target nodejs` From a04e204e796ac64efdd0799ba8d1a9d41b261bb7 Mon Sep 17 00:00:00 2001 From: Rom Grk Date: Wed, 21 Aug 2024 00:56:59 -0400 Subject: [PATCH 05/10] lint --- packages/hash-rust/index.js | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/packages/hash-rust/index.js b/packages/hash-rust/index.js index 1e4508df1..9ccc0e38e 100644 --- a/packages/hash-rust/index.js +++ b/packages/hash-rust/index.js @@ -1,29 +1,28 @@ -let imports = {}; -let wasm; - -const path = require('path').join(__dirname, './pkg/murmur_bg.wasm'); -const bytes = require('fs').readFileSync(path); -const wasmModule = new WebAssembly.Module(bytes); -const wasmInstance = new WebAssembly.Instance(wasmModule, imports); -wasm = wasmInstance.exports; +let imports = {} +let wasm +const path = require('path').join(__dirname, './pkg/murmur_bg.wasm') +const bytes = require('fs').readFileSync(path) +const wasmModule = new WebAssembly.Module(bytes) +const wasmInstance = new WebAssembly.Instance(wasmModule, imports) +wasm = wasmInstance.exports // Manually written to encode faster than wasm_bindgen does. let MEM_START = 32 // Alignement for the bytes slice -let memory = new Uint8Array(wasm.memory.buffer).subarray(MEM_START); -let cachedTextEncoder = new TextEncoder('utf-8'); +let memory = new Uint8Array(wasm.memory.buffer).subarray(MEM_START) +let cachedTextEncoder = new TextEncoder('utf-8') -module.exports.xxh = wrapStringToU32('xxh'); -module.exports.murmur2 = wrapStringToU32('murmur2'); +module.exports.xxh = wrapStringToU32('xxh') +module.exports.murmur2 = wrapStringToU32('murmur2') function wrapStringToU32(name) { return function(input) { - const ptr0 = MEM_START; - const len0 = cachedTextEncoder.encodeInto(input, memory).written; - const ret = wasm[name](ptr0, len0); - return ret; + const ptr0 = MEM_START + const len0 = cachedTextEncoder.encodeInto(input, memory).written + const ret = wasm[name](ptr0, len0) + return ret } } From 4785987094474e7c61b9b45fb11ebfaecf991309 Mon Sep 17 00:00:00 2001 From: Rom Grk Date: Wed, 21 Aug 2024 01:11:06 -0400 Subject: [PATCH 06/10] lint --- packages/hash-rust/index.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/hash-rust/index.js b/packages/hash-rust/index.js index 9ccc0e38e..a1e4f31fb 100644 --- a/packages/hash-rust/index.js +++ b/packages/hash-rust/index.js @@ -18,11 +18,10 @@ module.exports.xxh = wrapStringToU32('xxh') module.exports.murmur2 = wrapStringToU32('murmur2') function wrapStringToU32(name) { - return function(input) { - const ptr0 = MEM_START - const len0 = cachedTextEncoder.encodeInto(input, memory).written - const ret = wasm[name](ptr0, len0) - return ret + return (input) => { + const ptr0 = MEM_START + const len0 = cachedTextEncoder.encodeInto(input, memory).written + const ret = wasm[name](ptr0, len0) + return ret } } - From 34ed2e838eacbcbbc332f7233025658018e891c9 Mon Sep 17 00:00:00 2001 From: Rom Grk Date: Wed, 21 Aug 2024 02:40:16 -0400 Subject: [PATCH 07/10] lint --- packages/hash-rust/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/hash-rust/index.js b/packages/hash-rust/index.js index a1e4f31fb..599453a62 100644 --- a/packages/hash-rust/index.js +++ b/packages/hash-rust/index.js @@ -18,7 +18,7 @@ module.exports.xxh = wrapStringToU32('xxh') module.exports.murmur2 = wrapStringToU32('murmur2') function wrapStringToU32(name) { - return (input) => { + return input => { const ptr0 = MEM_START const len0 = cachedTextEncoder.encodeInto(input, memory).written const ret = wasm[name](ptr0, len0) From 09cbf8b5d9c3380b9bccfcaa95d3aa3aafae7223 Mon Sep 17 00:00:00 2001 From: Rom Grk Date: Thu, 22 Aug 2024 22:10:12 -0400 Subject: [PATCH 08/10] lint --- packages/hash-rust/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/hash-rust/src/lib.rs b/packages/hash-rust/src/lib.rs index 04e663435..87e1222a6 100644 --- a/packages/hash-rust/src/lib.rs +++ b/packages/hash-rust/src/lib.rs @@ -52,11 +52,11 @@ pub fn murmur2(bytes: *const u8, mut length: usize) -> u32 { } if length >= 1 { h ^= (unsafe { *bytes.add(i + 0) as u32 } & 0xff); - h = (h & 0xffff) * M + (((h >> 16) * 0xe995) << 16); + h *= M; } h ^= h >> 13; - h = (h & 0xffff) * M + (((h >> 16) * 0xe995) << 16); + h *= M; h = h ^ (h >> 15); return h; From 230f8eb2190069646b262682adb20bc08bd25847 Mon Sep 17 00:00:00 2001 From: Rom Grk Date: Thu, 22 Aug 2024 22:12:07 -0400 Subject: [PATCH 09/10] lint --- packages/hash-rust/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/hash-rust/src/lib.rs b/packages/hash-rust/src/lib.rs index 87e1222a6..f12c1dc8e 100644 --- a/packages/hash-rust/src/lib.rs +++ b/packages/hash-rust/src/lib.rs @@ -23,8 +23,8 @@ const R: u32 = 24; #[wasm_bindgen] pub fn murmur2(bytes: *const u8, mut length: usize) -> u32 { let data = unsafe { std::slice::from_raw_parts( - std::mem::transmute::<_, *const u32>(bytes), - length, // so wrong but doesnt matter + std::mem::transmute::<*const u8, *const u32>(bytes), + length / 4, // so wrong but doesnt matter ) }; let mut h = 0; // Not initialized to match emotion's implementation From 84220c3c1c94a78d9ea72449805a661bf9c924ee Mon Sep 17 00:00:00 2001 From: Rom Grk Date: Thu, 22 Aug 2024 22:18:22 -0400 Subject: [PATCH 10/10] lint --- packages/hash-rust/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/hash-rust/src/lib.rs b/packages/hash-rust/src/lib.rs index f12c1dc8e..5d3300467 100644 --- a/packages/hash-rust/src/lib.rs +++ b/packages/hash-rust/src/lib.rs @@ -24,7 +24,7 @@ const R: u32 = 24; pub fn murmur2(bytes: *const u8, mut length: usize) -> u32 { let data = unsafe { std::slice::from_raw_parts( std::mem::transmute::<*const u8, *const u32>(bytes), - length / 4, // so wrong but doesnt matter + length / 4, ) }; let mut h = 0; // Not initialized to match emotion's implementation