diff --git a/src/alloc.c b/src/alloc.c index 17ca5c725d0..62e96b4c9de 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -3140,6 +3140,7 @@ large_vector_vec (struct large_vector *p) vectors of the same NBYTES size, so NTH == VINDEX (NBYTES). */ static struct Lisp_Vector *vector_free_lists[VECTOR_MAX_FREE_LIST_INDEX]; +static int vector_free_lists_min_idx = VECTOR_MAX_FREE_LIST_INDEX; /* Singly-linked list of large vectors. */ @@ -3176,6 +3177,8 @@ setup_on_free_list (struct Lisp_Vector *v, ptrdiff_t nbytes) set_next_vector (v, vector_free_lists[vindex]); ASAN_POISON_VECTOR_CONTENTS (v, nbytes - header_size); vector_free_lists[vindex] = v; + if ( vindex < vector_free_lists_min_idx ) + vector_free_lists_min_idx = vindex; } /* Get a new vector block. */ @@ -3230,8 +3233,8 @@ allocate_vector_from_block (ptrdiff_t nbytes) /* Next, check free lists containing larger vectors. Since we will split the result, we should have remaining space large enough to use for one-slot vector at least. */ - for (index = VINDEX (nbytes + VBLOCK_BYTES_MIN); - index < VECTOR_MAX_FREE_LIST_INDEX; index++) + for (index = max ( VINDEX (nbytes + VBLOCK_BYTES_MIN), vector_free_lists_min_idx ); + index < VECTOR_MAX_FREE_LIST_INDEX; index++, vector_free_lists_min_idx++) if (vector_free_lists[index]) { /* This vector is larger than requested. */ @@ -3413,6 +3416,7 @@ sweep_vectors (void) gcstat.total_vectors = 0; gcstat.total_vector_slots = gcstat.total_free_vector_slots = 0; memset (vector_free_lists, 0, sizeof (vector_free_lists)); + vector_free_lists_min_idx = VECTOR_MAX_FREE_LIST_INDEX; /* Looking through vector blocks. */