From b8549ace92a7b515c111057f8790d6fb4fae7797 Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Wed, 11 May 2016 13:54:28 -0400 Subject: [PATCH] lib/core: Pre-allocate at least 16 slots when enlarging array Signed-off-by: Lucas Bajolet --- lib/core/collection/array.nit | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/core/collection/array.nit b/lib/core/collection/array.nit index 79e7a70af0..2331c325be 100644 --- a/lib/core/collection/array.nit +++ b/lib/core/collection/array.nit @@ -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