Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -897,11 +897,12 @@ STATIC_INLINE void jl_array_grow_at_end(jl_array_t *a, size_t idx,
if (__unlikely(reqmaxsize > a->maxsize)) {
size_t nb1 = idx * elsz;
size_t nbinc = inc * elsz;
// if the requested size is more than 2x current maxsize, grow exactly
// otherwise double the maxsize
size_t newmaxsize = reqmaxsize >= a->maxsize * 2
// if the requested size is more than 1.5x current maxsize, grow exactly
// otherwise use 1.5x the maxsize
size_t growmaxsize = (a->maxsize*3)>>1;
size_t newmaxsize = reqmaxsize >= growmaxsize
? (reqmaxsize < 4 ? 4 : reqmaxsize)
: a->maxsize * 2;
: growmaxsize;
newmaxsize = limit_overallocation(a, n, newmaxsize, inc);
size_t oldmaxsize = a->maxsize;
int newbuf = array_resize_buffer(a, newmaxsize);
Expand Down