tag | c8ed85a928c8a2708c736301b3f73241b03cd4a6 | |
---|---|---|
tagger | The Android Open Source Project <initial-contribution@android.com> | Wed Dec 15 20:38:49 2021 -0800 |
object | 0185340fd7cb53492b0a35f468feff4783dcb55b |
Android VTS 12.0 Release 2 (7973604)
commit | 0185340fd7cb53492b0a35f468feff4783dcb55b | [log] [tgz] |
---|---|---|
author | android-build-team Robot <android-build-team-robot@google.com> | Sun Feb 21 00:06:22 2021 +0000 |
committer | android-build-team Robot <android-build-team-robot@google.com> | Sun Feb 21 00:06:22 2021 +0000 |
tree | 16244a35292a0f1c14f6fbc0d6998e7e774c4ad7 | |
parent | 11ba21419a37414768b9024f4c037ba87ff4cf0a [diff] | |
parent | 2954af9095c522a554772dab87273d9b2c67e962 [diff] |
Snap for 7160059 from 2954af9095c522a554772dab87273d9b2c67e962 to sc-release Change-Id: I97df409d49983df325c063d6a1d23ba7795ba1c4
A speedy hash algorithm used within rustc. The hashmap in liballoc by default uses SipHash which isn‘t quite as speedy as we want. In the compiler we’re not really worried about DOS attempts, so we use a fast non-cryptographic hash.
This is the same as the algorithm used by Firefox -- which is a homespun one not based on any widely-known algorithm -- though modified to produce 64-bit hash values instead of 32-bit hash values. It consistently out-performs an FNV-based hash within rustc itself -- the collision rate is similar or slightly worse than FNV, but the speed of the hash function itself is much higher because it works on up to 8 bytes at a time.
use rustc_hash::FxHashMap; let mut map: FxHashMap<u32, u32> = FxHashMap::default(); map.insert(22, 44);
no_std
This crate can be used as a no_std
crate by disabling the std
feature, which is on by default, as follows:
rustc-hash = { version = "1.0", default-features = false }
In this configuration, FxHasher
is the only export, and the FxHashMap
/FxHashSet
type aliases are omitted.