Skip to content

Conversation

@mbrubeck
Copy link
Collaborator

The previous generic implementation was slow, and potentially incorrect for custom types. Fixes #142.

The previous generic implementation was slow, and potentially incorrect for custom types. Fixes #142.
@mbrubeck mbrubeck merged commit 8dcc1dc into master Feb 17, 2025
4 checks passed
Comment on lines +2039 to +2048
impl<T: PrimitiveFloat> Hash for OrderedFloat<T> {
fn hash<H: Hasher>(&self, hasher: &mut H) {
let bits = if self.0.is_nan() {
T::CANONICAL_NAN_BITS
} else {
self.0.canonical_bits()
};
bits.hash(hasher);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks the original hash result because it doesn't call raw_double_bits anymore.

Our use case depends on stable hash results. @mbrubeck would you give some background why change the result? (I can understand we implement only for f32/f64)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that. The main reason for that change was performance. (See #142 for details.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants