Skip to content

Commit

Permalink
lib/core: Pre-allocate at least 16 slots when enlarging array
Browse files Browse the repository at this point in the history
Signed-off-by: Lucas Bajolet <[email protected]>
  • Loading branch information
lbajolet committed May 12, 2016
1 parent ea71df8 commit b8549ac
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/core/collection/array.nit
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@ class Array[E]
do
var c = _capacity
if cap <= c then return
while c <= cap do c = c * 2 + 2
if c < 16 then c = 16
while c <= cap do c = c * 2
var a = new NativeArray[E](c)
if _capacity > 0 then _items.copy_to(a, _length)
_items = a
Expand Down

0 comments on commit b8549ac

Please sign in to comment.