From 29f71488bc50843b65660867ab41e6ebf1101e6e Mon Sep 17 00:00:00 2001 From: Shaun Steenkamp Date: Mon, 12 Feb 2018 14:00:08 +0000 Subject: [PATCH] 38880 remove redundant extra function --- src/libstd/collections/hash/map.rs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 04c9f617d019..d798854927d3 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -397,17 +397,6 @@ pub struct HashMap { resize_policy: DefaultResizePolicy, } -/// Search for a pre-hashed key when the hash map is known to be non-empty. -#[inline] -fn search_hashed_nonempty(table: M, hash: SafeHash, is_match: F) - -> InternalEntry - where M: Deref>, - F: FnMut(&K) -> bool -{ - // Do not check the capacity as an extra branch could slow the lookup. - search_hashed_body(table, hash, is_match) -} - /// Search for a pre-hashed key. /// If you don't already know the hash, use search or search_mut instead #[inline] @@ -422,16 +411,19 @@ fn search_hashed(table: M, hash: SafeHash, is_match: F) -> InternalE return InternalEntry::TableIsEmpty; } - search_hashed_body(table, hash, is_match) + search_hashed_nonempty(table, hash, is_match) } -/// The body of the search_hashed[_nonempty] functions + +/// Search for a pre-hashed key when the hash map is known to be non-empty. #[inline] -fn search_hashed_body(table: M, hash: SafeHash, mut is_match: F) +fn search_hashed_nonempty(table: M, hash: SafeHash, is_match: F) -> InternalEntry where M: Deref>, F: FnMut(&K) -> bool { + // Do not check the capacity as an extra branch could slow the lookup. + let size = table.size(); let mut probe = Bucket::new(table, hash); let mut displacement = 0;