Skip to content

Commit 3e414bd

Browse files
committed
Switch C++ std::hash<T> implementations to foldhash
1 parent b353d5e commit 3e414bd

File tree

4 files changed

+4
-238
lines changed

4 files changed

+4
-238
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ default = ["std", "cxxbridge-flags/default"] # c++11
2020
"c++17" = ["cxxbridge-flags/c++17"]
2121
"c++20" = ["cxxbridge-flags/c++20"]
2222
alloc = []
23-
std = ["alloc"]
23+
std = ["alloc", "foldhash/std"]
2424

2525
[dependencies]
2626
cxxbridge-macro = { version = "=1.0.130", path = "macro" }
27+
foldhash = { version = "0.1", default-features = false }
2728
link-cplusplus = "1.0.9"
2829

2930
[build-dependencies]

src/hash.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
use core::hash::{Hash, Hasher};
1+
use core::hash::{BuildHasher as _, Hash};
22

33
#[doc(hidden)]
44
pub fn hash<V: Hash>(value: &V) -> usize {
5-
#[cfg(feature = "std")]
6-
let mut hasher = std::collections::hash_map::DefaultHasher::new();
7-
#[cfg(not(feature = "std"))]
8-
let mut hasher = crate::sip::SipHasher13::new();
9-
10-
Hash::hash(value, &mut hasher);
11-
Hasher::finish(&hasher) as usize
5+
foldhash::quality::FixedState::default().hash_one(value) as usize
126
}

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,6 @@ mod rust_string;
466466
mod rust_type;
467467
mod rust_vec;
468468
mod shared_ptr;
469-
mod sip;
470469
#[path = "cxx_string.rs"]
471470
mod string;
472471
mod symbols;

src/sip.rs

Lines changed: 0 additions & 228 deletions
This file was deleted.

0 commit comments

Comments
 (0)