-
Notifications
You must be signed in to change notification settings - Fork 41
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
Resetting the hash #72
Comments
I don't see a particular benefit to having a reset function — I'd just replace the hash value directly and expect the compiler to make up the difference. |
Hmm, suppose I have the following operations: let mut hash = XxHash64::with_seed(0);
hash.write(...);
// reset here How would I replace the internal hash value with a new one based on a seed S? |
I must be missing something. Wouldn't you do let mut hash = XxHash64::with_seed(0);
hash.write(...);
// reset here
let mut hash = XxHash64::with_seed(0); |
Oh, I see, basically creating a new one. So if I need to use in a struct, that would be: struct MyObject{
hash: Cell<XxHash64>, // or something else with interior mutability
} Right? |
I'd expect that you'd make the methods take struct MyObject{
hash: XxHash64,
}
impl MyObject {
fn foo(&mut self) {
self.hash.write(...);
self.hash = XxHash64::new();
}
} but sure, if you need interior mutability for some other reason, that also works. |
That's one option indeed. Thanks for your quick responses! Stay safe. |
Hi, thanks for porting this to Rust! Is there anything similar to
XXH64_reset
to reset/reuse the hash? Or should I make a new one usingnew
? Thanks in advance!Regards,
The text was updated successfully, but these errors were encountered: