From 1723e18b1d92c3fe6d60ea8cef514901cac8e5ba Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 25 Apr 2014 02:28:32 +0200 Subject: Reduce minimum vector allocation --- src/vector.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/vector.c b/src/vector.c index 153327e..bda1fe1 100644 --- a/src/vector.c +++ b/src/vector.c @@ -29,8 +29,11 @@ #include +#define MIN_VECTOR_ALLOC 4 + + void _fastd_vector_alloc(fastd_vector_desc_t *desc, void **data, size_t n, size_t elemsize) { - desc->allocated = 16; + desc->allocated = MIN_VECTOR_ALLOC; while (desc->allocated < n*3/2) desc->allocated <<= 1; @@ -47,7 +50,7 @@ void _fastd_vector_resize(fastd_vector_desc_t *desc, void **data, size_t n, size while (alloc < n) alloc <<= 1; - while (alloc > n*3 && alloc > 16) + while (alloc > n*3 && alloc > MIN_VECTOR_ALLOC) alloc >>= 1; if (alloc != desc->allocated) { -- cgit v1.2.3