From daf5bd564a0eb8ff7784f85a015cbe4f06ac162e Mon Sep 17 00:00:00 2001 From: Jonathan Behrens Date: Wed, 31 Oct 2018 15:15:20 -0400 Subject: [PATCH] A couple suggested edits --- src/libstd/collections/hash/map.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 8b5957abe59..4a62649434c 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -477,7 +477,7 @@ fn search_hashed_nonempty(table: M, hash: SafeHash, mut is_match: F, } // If the hash doesn't match, it can't be this one.. - if hash == full.hash() || !compare_hashes { + if !compare_hashes || hash == full.hash() { // If the key doesn't match, it can't be this one.. if is_match(full.read().0) { return InternalEntry::Occupied { elem: full }; @@ -489,7 +489,7 @@ fn search_hashed_nonempty(table: M, hash: SafeHash, mut is_match: F, } } -/// Search for a pre-hashed key when the hash map is known to be non-empty. +/// Same as `search_hashed_nonempty` but for mutable access. #[inline] fn search_hashed_nonempty_mut(table: M, hash: SafeHash, mut is_match: F, compare_hashes: bool) @@ -1571,10 +1571,6 @@ impl HashMap /// so that the map now contains keys which compare equal, search may start /// acting eratically, with two keys randomly masking eachother. Implementations /// are free to assume this doesn't happen (within the limits of memory-safety). - /// - /// # Examples - /// - /// #[unstable(feature = "hash_raw_entry", issue = "54043")] pub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut { self.reserve(1); @@ -1595,7 +1591,7 @@ impl HashMap /// Unless you are in such a situation, higher-level and more foolproof APIs like /// `get` should be preferred. /// - /// Immutable raw entries have very limited use; you might instead want `raw_entry`. + /// Immutable raw entries have very limited use; you might instead want `raw_entry_mut`. #[unstable(feature = "hash_raw_entry", issue = "54043")] pub fn raw_entry(&self) -> RawEntryBuilder { RawEntryBuilder { map: self }