@@ -802,7 +802,11 @@ where
802802 K : Borrow < Q > ,
803803 Q : Hash + Eq ,
804804 {
805- self . get_key_value ( k) . map ( |( _, v) | v)
805+ // Avoid `Option::map` because it bloats LLVM IR.
806+ match self . get_key_value ( k) {
807+ Some ( ( _, v) ) => Some ( v) ,
808+ None => None ,
809+ }
806810 }
807811
808812 /// Returns the key-value pair corresponding to the supplied key.
@@ -831,12 +835,14 @@ where
831835 Q : Hash + Eq ,
832836 {
833837 let hash = make_hash ( & self . hash_builder , k) ;
834- self . table
835- . find ( hash, |x| k. eq ( x. 0 . borrow ( ) ) )
836- . map ( | item| unsafe {
838+ // Avoid `Option::map` because it bloats LLVM IR.
839+ match self . table . find ( hash, |x| k. eq ( x. 0 . borrow ( ) ) ) {
840+ Some ( item) => unsafe {
837841 let & ( ref key, ref value) = item. as_ref ( ) ;
838- ( key, value)
839- } )
842+ Some ( ( key, value) )
843+ }
844+ None => None ,
845+ }
840846 }
841847
842848 /// Returns the key-value pair corresponding to the supplied key, with a mutable reference to value.
@@ -869,12 +875,14 @@ where
869875 Q : Hash + Eq ,
870876 {
871877 let hash = make_hash ( & self . hash_builder , k) ;
872- self . table
873- . find ( hash, |x| k. eq ( x. 0 . borrow ( ) ) )
874- . map ( | item| unsafe {
878+ // Avoid `Option::map` because it bloats LLVM IR.
879+ match self . table . find ( hash, |x| k. eq ( x. 0 . borrow ( ) ) ) {
880+ Some ( item) => unsafe {
875881 let & mut ( ref key, ref mut value) = item. as_mut ( ) ;
876- ( key, value)
877- } )
882+ Some ( ( key, value) )
883+ }
884+ None => None ,
885+ }
878886 }
879887
880888 /// Returns `true` if the map contains a value for the specified key.
@@ -933,9 +941,11 @@ where
933941 Q : Hash + Eq ,
934942 {
935943 let hash = make_hash ( & self . hash_builder , k) ;
936- self . table
937- . find ( hash, |x| k. eq ( x. 0 . borrow ( ) ) )
938- . map ( |item| unsafe { & mut item. as_mut ( ) . 1 } )
944+ // Avoid `Option::map` because it bloats LLVM IR.
945+ match self . table . find ( hash, |x| k. eq ( x. 0 . borrow ( ) ) ) {
946+ Some ( item) => Some ( unsafe { & mut item. as_mut ( ) . 1 } ) ,
947+ None => None ,
948+ }
939949 }
940950
941951 /// Inserts a key-value pair into the map.
@@ -1004,7 +1014,11 @@ where
10041014 K : Borrow < Q > ,
10051015 Q : Hash + Eq ,
10061016 {
1007- self . remove_entry ( k) . map ( |( _, v) | v)
1017+ // Avoid `Option::map` because it bloats LLVM IR.
1018+ match self . remove_entry ( k) {
1019+ Some ( ( _, v) ) => Some ( v) ,
1020+ None => None ,
1021+ }
10081022 }
10091023
10101024 /// Removes a key from the map, returning the stored key and value if the
@@ -1561,13 +1575,13 @@ impl<'a, K, V, S> RawEntryBuilder<'a, K, V, S> {
15611575 where
15621576 F : FnMut ( & K ) -> bool ,
15631577 {
1564- self . map
1565- . table
1566- . find ( hash, |( k, _) | is_match ( k) )
1567- . map ( |item| unsafe {
1578+ match self . map . table . find ( hash, |( k, _) | is_match ( k) ) {
1579+ Some ( item) => unsafe {
15681580 let & ( ref key, ref value) = item. as_ref ( ) ;
1569- ( key, value)
1570- } )
1581+ Some ( ( key, value) )
1582+ }
1583+ None => None ,
1584+ }
15711585 }
15721586
15731587 /// Access an entry by hash.
@@ -2030,10 +2044,14 @@ impl<'a, K, V> Iterator for Iter<'a, K, V> {
20302044
20312045 #[ cfg_attr( feature = "inline-more" , inline) ]
20322046 fn next ( & mut self ) -> Option < ( & ' a K , & ' a V ) > {
2033- self . inner . next ( ) . map ( |x| unsafe {
2034- let r = x. as_ref ( ) ;
2035- ( & r. 0 , & r. 1 )
2036- } )
2047+ // Avoid `Option::map` because it bloats LLVM IR.
2048+ match self . inner . next ( ) {
2049+ Some ( x) => unsafe {
2050+ let r = x. as_ref ( ) ;
2051+ Some ( ( & r. 0 , & r. 1 ) )
2052+ }
2053+ None => None ,
2054+ }
20372055 }
20382056 #[ cfg_attr( feature = "inline-more" , inline) ]
20392057 fn size_hint ( & self ) -> ( usize , Option < usize > ) {
@@ -2054,10 +2072,14 @@ impl<'a, K, V> Iterator for IterMut<'a, K, V> {
20542072
20552073 #[ cfg_attr( feature = "inline-more" , inline) ]
20562074 fn next ( & mut self ) -> Option < ( & ' a K , & ' a mut V ) > {
2057- self . inner . next ( ) . map ( |x| unsafe {
2058- let r = x. as_mut ( ) ;
2059- ( & r. 0 , & mut r. 1 )
2060- } )
2075+ // Avoid `Option::map` because it bloats LLVM IR.
2076+ match self . inner . next ( ) {
2077+ Some ( x) => unsafe {
2078+ let r = x. as_mut ( ) ;
2079+ Some ( ( & r. 0 , & mut r. 1 ) )
2080+ }
2081+ None => None ,
2082+ }
20612083 }
20622084 #[ cfg_attr( feature = "inline-more" , inline) ]
20632085 fn size_hint ( & self ) -> ( usize , Option < usize > ) {
@@ -2113,7 +2135,11 @@ impl<'a, K, V> Iterator for Keys<'a, K, V> {
21132135
21142136 #[ cfg_attr( feature = "inline-more" , inline) ]
21152137 fn next ( & mut self ) -> Option < & ' a K > {
2116- self . inner . next ( ) . map ( |( k, _) | k)
2138+ // Avoid `Option::map` because it bloats LLVM IR.
2139+ match self . inner . next ( ) {
2140+ Some ( ( k, _) ) => Some ( k) ,
2141+ None => None ,
2142+ }
21172143 }
21182144 #[ cfg_attr( feature = "inline-more" , inline) ]
21192145 fn size_hint ( & self ) -> ( usize , Option < usize > ) {
@@ -2133,7 +2159,11 @@ impl<'a, K, V> Iterator for Values<'a, K, V> {
21332159
21342160 #[ cfg_attr( feature = "inline-more" , inline) ]
21352161 fn next ( & mut self ) -> Option < & ' a V > {
2136- self . inner . next ( ) . map ( |( _, v) | v)
2162+ // Avoid `Option::map` because it bloats LLVM IR.
2163+ match self . inner . next ( ) {
2164+ Some ( ( _, v) ) => Some ( v) ,
2165+ None => None ,
2166+ }
21372167 }
21382168 #[ cfg_attr( feature = "inline-more" , inline) ]
21392169 fn size_hint ( & self ) -> ( usize , Option < usize > ) {
@@ -2153,7 +2183,11 @@ impl<'a, K, V> Iterator for ValuesMut<'a, K, V> {
21532183
21542184 #[ cfg_attr( feature = "inline-more" , inline) ]
21552185 fn next ( & mut self ) -> Option < & ' a mut V > {
2156- self . inner . next ( ) . map ( |( _, v) | v)
2186+ // Avoid `Option::map` because it bloats LLVM IR.
2187+ match self . inner . next ( ) {
2188+ Some ( ( _, v) ) => Some ( v) ,
2189+ None => None ,
2190+ }
21572191 }
21582192 #[ cfg_attr( feature = "inline-more" , inline) ]
21592193 fn size_hint ( & self ) -> ( usize , Option < usize > ) {
0 commit comments