1- use super :: EitherIter ;
1+ use super :: either_iter :: EitherIter ;
22use crate :: fx:: FxHashMap ;
33use arrayvec:: ArrayVec ;
44use std:: borrow:: Borrow ;
@@ -32,6 +32,7 @@ pub enum SsoHashMap<K, V> {
3232
3333impl < K , V > SsoHashMap < K , V > {
3434 /// Creates an empty `SsoHashMap`.
35+ #[ inline]
3536 pub fn new ( ) -> Self {
3637 SsoHashMap :: Array ( ArrayVec :: new ( ) )
3738 }
@@ -81,13 +82,15 @@ impl<K, V> SsoHashMap<K, V> {
8182
8283 /// An iterator visiting all key-value pairs in arbitrary order.
8384 /// The iterator element type is `(&'a K, &'a V)`.
84- pub fn iter ( & self ) -> impl Iterator < Item = ( & ' _ K , & ' _ V ) > {
85+ #[ inline]
86+ pub fn iter ( & self ) -> <& Self as IntoIterator >:: IntoIter {
8587 self . into_iter ( )
8688 }
8789
8890 /// An iterator visiting all key-value pairs in arbitrary order,
8991 /// with mutable references to the values.
9092 /// The iterator element type is `(&'a K, &'a mut V)`.
93+ #[ inline]
9194 pub fn iter_mut ( & mut self ) -> impl Iterator < Item = ( & ' _ K , & ' _ mut V ) > {
9295 self . into_iter ( )
9396 }
@@ -319,12 +322,14 @@ impl<K: Eq + Hash, V> SsoHashMap<K, V> {
319322 }
320323
321324 /// Gets the given key's corresponding entry in the map for in-place manipulation.
325+ #[ inline]
322326 pub fn entry ( & mut self , key : K ) -> Entry < ' _ , K , V > {
323327 Entry { ssomap : self , key }
324328 }
325329}
326330
327331impl < K , V > Default for SsoHashMap < K , V > {
332+ #[ inline]
328333 fn default ( ) -> Self {
329334 Self :: new ( )
330335 }
@@ -348,6 +353,7 @@ impl<K: Eq + Hash, V> Extend<(K, V)> for SsoHashMap<K, V> {
348353 }
349354 }
350355
356+ #[ inline]
351357 fn extend_one ( & mut self , ( k, v) : ( K , V ) ) {
352358 self . insert ( k, v) ;
353359 }
@@ -375,10 +381,12 @@ where
375381 self . extend ( iter. into_iter ( ) . map ( |( k, v) | ( k. clone ( ) , v. clone ( ) ) ) )
376382 }
377383
384+ #[ inline]
378385 fn extend_one ( & mut self , ( & k, & v) : ( & ' a K , & ' a V ) ) {
379386 self . insert ( k, v) ;
380387 }
381388
389+ #[ inline]
382390 fn extend_reserve ( & mut self , additional : usize ) {
383391 Extend :: < ( K , V ) > :: extend_reserve ( self , additional)
384392 }
@@ -400,12 +408,14 @@ impl<K, V> IntoIterator for SsoHashMap<K, V> {
400408}
401409
402410/// adapts Item of array reference iterator to Item of hashmap reference iterator.
411+ #[ inline( always) ]
403412fn adapt_array_ref_it < K , V > ( pair : & ' a ( K , V ) ) -> ( & ' a K , & ' a V ) {
404413 let ( a, b) = pair;
405414 ( a, b)
406415}
407416
408417/// adapts Item of array mut reference iterator to Item of hashmap mut reference iterator.
418+ #[ inline( always) ]
409419fn adapt_array_mut_it < K , V > ( pair : & ' a mut ( K , V ) ) -> ( & ' a K , & ' a mut V ) {
410420 let ( a, b) = pair;
411421 ( a, b)
@@ -464,6 +474,7 @@ where
464474{
465475 type Output = V ;
466476
477+ #[ inline]
467478 fn index ( & self , key : & Q ) -> & V {
468479 self . get ( key) . expect ( "no entry found for key" )
469480 }
@@ -490,6 +501,7 @@ impl<'a, K: Eq + Hash, V> Entry<'a, K, V> {
490501
491502 /// Ensures a value is in the entry by inserting the default if empty, and returns
492503 /// a mutable reference to the value in the entry.
504+ #[ inline]
493505 pub fn or_insert ( self , value : V ) -> & ' a mut V {
494506 self . or_insert_with ( || value)
495507 }
@@ -515,6 +527,7 @@ impl<'a, K: Eq + Hash, V> Entry<'a, K, V> {
515527 }
516528
517529 /// Returns a reference to this entry's key.
530+ #[ inline]
518531 pub fn key ( & self ) -> & K {
519532 & self . key
520533 }
@@ -523,6 +536,7 @@ impl<'a, K: Eq + Hash, V> Entry<'a, K, V> {
523536impl < ' a , K : Eq + Hash , V : Default > Entry < ' a , K , V > {
524537 /// Ensures a value is in the entry by inserting the default value if empty,
525538 /// and returns a mutable reference to the value in the entry.
539+ #[ inline]
526540 pub fn or_default ( self ) -> & ' a mut V {
527541 self . or_insert_with ( Default :: default)
528542 }
0 commit comments