File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -1087,14 +1087,14 @@ end
10871087#  Specifically we are wasting ~10% of memory for small arrays
10881088#  by not picking memory sizes that max out a GC pool
10891089function  overallocation (maxsize)
1090-     maxsize <  8  &&  return  8 ;
1091-     #  compute maxsize = maxsize + 4*maxsize^(7/8) + maxsize/8
1090+     #  compute maxsize = maxsize + 3*maxsize^(7/8) + maxsize/8
10921091    #  for small n, we grow faster than O(n)
10931092    #  for large n, we grow at O(n/8)
10941093    #  and as we reach O(memory) for memory>>1MB,
10951094    #  this means we end by adding about 10% of memory each time
1095+     #  most commonly, this will take steps of 0-3-9-34 or 1-4-16-66 or 2-8-33
10961096    exp2 =  sizeof (maxsize) *  8  -  Core. Intrinsics. ctlz_int (maxsize)
1097-     maxsize +=  (1  <<  div (exp2 *  7 , 8 )) *  4  +  div (maxsize, 8 )
1097+     maxsize +=  (1  <<  div (exp2 *  7 , 8 )) *  3  +  div (maxsize, 8 )
10981098    return  maxsize
10991099end 
11001100
Original file line number Diff line number Diff line change 525525    v =  empty! (collect (1 : 100 ))
526526    pushfirst! (v, 1 )
527527    @test  length (v. ref. mem) ==  100 
528+ 
529+     #  test that insert! at position 1 doesn't allocate for empty arrays with capacity (issue #58640)
530+     v =  empty! (Vector {Int} (undef, 5 ))
531+     insert! (v, 1 , 10 )
532+     @test  v ==  [10 ]
533+     @test  length (v. ref. mem) ==  5 
528534end 
529535
530536@testset  " popat!(::Vector, i, [default])" begin 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments