diff options
| author | kennytm <kennytm@gmail.com> | 2018-12-07 12:42:35 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-12-07 12:42:35 +0800 |
| commit | 06f3b57633aae7bbdbd3106d144eba5d0b6aee1b (patch) | |
| tree | 98e6a992759735e8b21e2201d3339591face6e02 /src/libstd | |
| parent | aa5ba8315ad022c4ad73d2e4e011d6e17bd6f056 (diff) | |
| parent | 7df4b812f07c503dc10037797f80a9aaa6b84aac (diff) | |
| download | rust-06f3b57633aae7bbdbd3106d144eba5d0b6aee1b.tar.gz rust-06f3b57633aae7bbdbd3106d144eba5d0b6aee1b.zip | |
Rollup merge of #56561 - Zoxc:too-raw, r=Gankro
Fix bug in from_key_hashed_nocheck
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/collections/hash/map.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 1eea920c623..55a1a75d049 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -11,6 +11,7 @@ use self::Entry::*; use self::VacantEntryState::*; +use intrinsics::unlikely; use collections::CollectionAllocErr; use cell::Cell; use borrow::Borrow; @@ -1992,6 +1993,9 @@ impl<'a, K, V, S> RawEntryBuilder<'a, K, V, S> fn search<F>(self, hash: u64, is_match: F, compare_hashes: bool) -> Option<(&'a K, &'a V)> where F: FnMut(&K) -> bool { + if unsafe { unlikely(self.map.table.size() == 0) } { + return None; + } match search_hashed_nonempty(&self.map.table, SafeHash::new(hash), is_match, |
