@@ -18,7 +18,7 @@ use core::mem::replace;
1818use core:: ops:: RangeBounds ;
1919
2020use crate :: equivalent:: Equivalent ;
21- use crate :: util:: { enumerate , simplify_range} ;
21+ use crate :: util:: simplify_range;
2222use crate :: { Bucket , Entries , HashValue } ;
2323
2424/// Core of the map that does not depend on S
@@ -185,9 +185,7 @@ impl<K, V> IndexMapCore<K, V> {
185185 let entries = self . entries . split_off ( at) ;
186186
187187 let mut indices = RawTable :: with_capacity ( entries. len ( ) ) ;
188- for ( i, entry) in enumerate ( & entries) {
189- indices. insert_no_grow ( entry. hash . get ( ) , i) ;
190- }
188+ raw:: insert_bulk_no_grow ( & mut indices, & entries) ;
191189 Self { indices, entries }
192190 }
193191
@@ -372,15 +370,9 @@ impl<K, V> IndexMapCore<K, V> {
372370 // Reinsert everything, as there are few kept indices
373371 self . indices . clear ( ) ;
374372
375- // Reinsert stable indices
376- for ( i, entry) in enumerate ( start_entries) {
377- self . indices . insert_no_grow ( entry. hash . get ( ) , i) ;
378- }
379-
380- // Reinsert shifted indices
381- for ( i, entry) in ( start..) . zip ( shifted_entries) {
382- self . indices . insert_no_grow ( entry. hash . get ( ) , i) ;
383- }
373+ // Reinsert stable indices, then shifted indices
374+ raw:: insert_bulk_no_grow ( & mut self . indices , start_entries) ;
375+ raw:: insert_bulk_no_grow ( & mut self . indices , shifted_entries) ;
384376 } else if erased + shifted < half_capacity {
385377 // Find each affected index, as there are few to adjust
386378
@@ -429,11 +421,7 @@ impl<K, V> IndexMapCore<K, V> {
429421
430422 fn rebuild_hash_table ( & mut self ) {
431423 self . indices . clear ( ) ;
432- debug_assert ! ( self . indices. capacity( ) >= self . entries. len( ) ) ;
433- for ( i, entry) in enumerate ( & self . entries ) {
434- // We should never have to reallocate, so there's no need for a real hasher.
435- self . indices . insert_no_grow ( entry. hash . get ( ) , i) ;
436- }
424+ raw:: insert_bulk_no_grow ( & mut self . indices , & self . entries ) ;
437425 }
438426
439427 pub ( crate ) fn reverse ( & mut self ) {
0 commit comments