File tree 1 file changed +8
-3
lines changed 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -649,10 +649,10 @@ impl<T> RawTable<T> {
649
649
#[ inline]
650
650
pub fn clear_no_drop ( & mut self ) {
651
651
unsafe {
652
- if ! self . is_empty_singleton ( ) {
653
- self . ctrl ( 0 ) . write_bytes ( EMPTY , self . num_ctrl_bytes ( ) ) ;
652
+ if self . is_empty_singleton ( ) {
653
+ return ;
654
654
}
655
-
655
+ self . ctrl ( 0 ) . write_bytes ( EMPTY , self . num_ctrl_bytes ( ) ) ;
656
656
let header = self . header_mut ( ) ;
657
657
header. items = 0 ;
658
658
header. growth_left = bucket_mask_to_capacity ( header. bucket_mask ) ;
@@ -869,6 +869,11 @@ impl<T> RawTable<T> {
869
869
870
870
// Allocate and initialize the new table.
871
871
let mut new_table = Self :: try_with_capacity ( capacity, fallability) ?;
872
+ if new_table. is_empty_singleton ( ) {
873
+ mem:: swap ( self , & mut new_table) ;
874
+ return Ok ( ( ) ) ;
875
+ }
876
+
872
877
let new_header = new_table. header_mut ( ) ;
873
878
new_header. growth_left -= self . items ( ) ;
874
879
new_header. items = self . items ( ) ;
You can’t perform that action at this time.
0 commit comments