@@ -18,7 +18,7 @@ use core::mem::replace;
18
18
use core:: ops:: RangeBounds ;
19
19
20
20
use crate :: equivalent:: Equivalent ;
21
- use crate :: util:: { enumerate , simplify_range} ;
21
+ use crate :: util:: simplify_range;
22
22
use crate :: { Bucket , Entries , HashValue } ;
23
23
24
24
/// Core of the map that does not depend on S
@@ -185,9 +185,7 @@ impl<K, V> IndexMapCore<K, V> {
185
185
let entries = self . entries . split_off ( at) ;
186
186
187
187
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) ;
191
189
Self { indices, entries }
192
190
}
193
191
@@ -372,15 +370,9 @@ impl<K, V> IndexMapCore<K, V> {
372
370
// Reinsert everything, as there are few kept indices
373
371
self . indices . clear ( ) ;
374
372
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) ;
384
376
} else if erased + shifted < half_capacity {
385
377
// Find each affected index, as there are few to adjust
386
378
@@ -429,11 +421,7 @@ impl<K, V> IndexMapCore<K, V> {
429
421
430
422
fn rebuild_hash_table ( & mut self ) {
431
423
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 ) ;
437
425
}
438
426
439
427
pub ( crate ) fn reverse ( & mut self ) {
0 commit comments