diff options
Diffstat (limited to 'src/librustc_data_structures/sharded.rs')
| -rw-r--r-- | src/librustc_data_structures/sharded.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/librustc_data_structures/sharded.rs b/src/librustc_data_structures/sharded.rs index 2f972eeccdc..a28a5e0f041 100644 --- a/src/librustc_data_structures/sharded.rs +++ b/src/librustc_data_structures/sharded.rs @@ -60,6 +60,7 @@ impl<T> Sharded<T> { } } + /// The shard is selected by hashing `val` with `FxHasher`. #[inline] pub fn get_shard_by_value<K: Hash + ?Sized>(&self, val: &K) -> &Lock<T> { if SHARDS == 1 { @@ -69,6 +70,11 @@ impl<T> Sharded<T> { } } + /// Get a shard with a pre-computed hash value. If `get_shard_by_value` is + /// ever used in combination with `get_shard_by_hash` on a single `Sharded` + /// instance, then `hash` must be computed with `FxHasher`. Otherwise, + /// `hash` can be computed with any hasher, so long as that hasher is used + /// consistently for each `Sharded` instance. #[inline] pub fn get_shard_by_hash(&self, hash: u64) -> &Lock<T> { let hash_len = mem::size_of::<usize>(); |
