File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -442,17 +442,21 @@ impl<T> Slab<T> {
442442 self . next = self . entries . len ( ) ;
443443 // We can stop once we've found all vacant entries
444444 let mut remaining_vacant = self . entries . len ( ) - self . len ;
445+ if remaining_vacant == 0 {
446+ return ;
447+ }
448+
445449 // Iterate in reverse order so that lower keys are at the start of
446450 // the vacant list. This way future shrinks are more likely to be
447451 // able to remove vacant entries.
448452 for ( i, entry) in self . entries . iter_mut ( ) . enumerate ( ) . rev ( ) {
449- if remaining_vacant == 0 {
450- break ;
451- }
452453 if let Entry :: Vacant ( ref mut next) = * entry {
453454 * next = self . next ;
454455 self . next = i;
455456 remaining_vacant -= 1 ;
457+ if remaining_vacant == 0 {
458+ break ;
459+ }
456460 }
457461 }
458462 }
You can’t perform that action at this time.
0 commit comments