File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -483,6 +483,8 @@ mod lgalloc {
483
483
#[ inline]
484
484
fn clear ( & mut self ) {
485
485
self . slices . clear ( ) ;
486
+ self . offsets . clear ( ) ;
487
+ self . offsets . push ( 0 ) ;
486
488
}
487
489
488
490
#[ inline]
Original file line number Diff line number Diff line change @@ -554,14 +554,18 @@ mod vec {
554
554
}
555
555
}
556
556
557
+ const MIN_NON_ZERO_CAP : usize = if std:: mem:: size_of :: < T > ( ) == 1 {
558
+ 8
559
+ } else if std:: mem:: size_of :: < T > ( ) <= 1024 {
560
+ 4
561
+ } else {
562
+ 1
563
+ } ;
564
+
557
565
/// Grow the array to at least `new_len` elements. Reallocates the underlying storage.
558
566
fn grow ( & mut self , new_len : usize ) {
559
567
let new_capacity = std:: cmp:: max ( self . capacity ( ) * 2 , new_len) ;
560
- println ! (
561
- "Reallocating {} -> {}, requested {new_len}" ,
562
- self . capacity( ) ,
563
- new_capacity
564
- ) ;
568
+ let new_capacity = std:: cmp:: max ( new_capacity, Self :: MIN_NON_ZERO_CAP ) ;
565
569
let mut new_vec = LgAllocVec :: with_capacity ( new_capacity) ;
566
570
567
571
let src_ptr = self . elements . as_ptr ( ) ;
You can’t perform that action at this time.
0 commit comments