-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
write_*
methods for DefaultHasher
, SipHasher
, SipHasher13
…
…, `sip::Hasher`. `sip::Hasher::short_write` is currently unused. It is called by `sip::Hasher::write_{u8,usize}`, but those methods are also unused, because `DefaultHasher`, `SipHasher` and `SipHasher13` don't implement any of the `write_xyz` methods, so all their write operations end up calling `sip::Hasher::write`. I confirmed this by inserting a `panic!` in `sip::Hasher::short_write` and running the tests -- they all passed. This commit adds all the `write_xyz` methods to `DefaultHasher`, `SipHasher`, `SipHasher13` and `sip::Hasher`, which means that `short_write` will be used for all of them. (I haven't properly implemented 128-bit writes in `sip::Hasher` and `SipHasher128`. That could be a follow-up if something thinks it is important.) Some microbenchmarks I wrote show that this commit speeds up default hashing of integers by about 2.5x, and can speed up hash tables that use `DefaultHasher` and have keys that contain integers by up to 30%, though the exact amount depends heavily on the details of the keys and how the table is used. This makes default `Hash{Map,Set}` much more likely to be competitive with `FxHash{Map,Set}`.
- Loading branch information
1 parent
f272983
commit 96c4e42
Showing
3 changed files
with
228 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters