diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-12-22 16:22:39 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-12-22 16:22:39 -0500 |
| commit | dcab9eb748bc092347c0f46565c9ff2c8933b06d (patch) | |
| tree | f88b83c05dc3dbf65a8cfa4a37657606c99452f9 | |
| parent | a9fe674446b4c3a3acf15835cc157bad723363ee (diff) | |
Tweak array resizing policy
| -rw-r--r-- | stdlib/arrays.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/stdlib/arrays.c b/stdlib/arrays.c index c8ee55bd..e5ffbfd4 100644 --- a/stdlib/arrays.c +++ b/stdlib/arrays.c @@ -64,7 +64,8 @@ public void Array$insert(Array_t *arr, const void *item, Int_t int_index, int64_ : GC_MALLOC((size_t)arr->free * (size_t)padded_item_size); arr->stride = padded_item_size; } else if (arr->free < 1 || arr->data_refcount != 0 || (int64_t)arr->stride != padded_item_size) { - arr->free = MIN(ARRAY_MAX_FREE_ENTRIES, MAX(8, arr->length/4)); + // Resize policy: +50% growth (clamped between 8 and ARRAY_MAX_FREE_ENTRIES) + arr->free = MIN(ARRAY_MAX_FREE_ENTRIES, MAX(8, arr->length)/2); void *copy = arr->atomic ? GC_MALLOC_ATOMIC((size_t)(arr->length + arr->free) * (size_t)padded_item_size) : GC_MALLOC((size_t)(arr->length + arr->free) * (size_t)padded_item_size); for (int64_t i = 0; i < index-1; i++) |
