mirror of
https://github.com/python/cpython.git
synced 2025-08-27 12:16:04 +00:00
gh-111968: Split _Py_dictkeys_freelist out of _Py_dict_freelist (gh-115505)
This commit is contained in:
parent
454d7963e3
commit
321d13fd2b
7 changed files with 77 additions and 59 deletions
|
@ -344,8 +344,8 @@ _context_alloc(void)
|
|||
struct _Py_context_freelist *context_freelist = get_context_freelist();
|
||||
if (context_freelist->numfree > 0) {
|
||||
context_freelist->numfree--;
|
||||
ctx = context_freelist->freelist;
|
||||
context_freelist->freelist = (PyContext *)ctx->ctx_weakreflist;
|
||||
ctx = context_freelist->items;
|
||||
context_freelist->items = (PyContext *)ctx->ctx_weakreflist;
|
||||
OBJECT_STAT_INC(from_freelist);
|
||||
ctx->ctx_weakreflist = NULL;
|
||||
_Py_NewReference((PyObject *)ctx);
|
||||
|
@ -471,8 +471,8 @@ context_tp_dealloc(PyContext *self)
|
|||
struct _Py_context_freelist *context_freelist = get_context_freelist();
|
||||
if (context_freelist->numfree >= 0 && context_freelist->numfree < PyContext_MAXFREELIST) {
|
||||
context_freelist->numfree++;
|
||||
self->ctx_weakreflist = (PyObject *)context_freelist->freelist;
|
||||
context_freelist->freelist = self;
|
||||
self->ctx_weakreflist = (PyObject *)context_freelist->items;
|
||||
context_freelist->items = self;
|
||||
OBJECT_STAT_INC(to_freelist);
|
||||
}
|
||||
else
|
||||
|
@ -1272,8 +1272,8 @@ _PyContext_ClearFreeList(struct _Py_object_freelists *freelists, int is_finaliza
|
|||
#ifdef WITH_FREELISTS
|
||||
struct _Py_context_freelist *state = &freelists->contexts;
|
||||
for (; state->numfree > 0; state->numfree--) {
|
||||
PyContext *ctx = state->freelist;
|
||||
state->freelist = (PyContext *)ctx->ctx_weakreflist;
|
||||
PyContext *ctx = state->items;
|
||||
state->items = (PyContext *)ctx->ctx_weakreflist;
|
||||
ctx->ctx_weakreflist = NULL;
|
||||
PyObject_GC_Del(ctx);
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@ _PyObjectStackChunk_New(void)
|
|||
_PyObjectStackChunk *buf;
|
||||
struct _Py_object_stack_freelist *obj_stack_freelist = get_object_stack_freelist();
|
||||
if (obj_stack_freelist->numfree > 0) {
|
||||
buf = obj_stack_freelist->free_list;
|
||||
obj_stack_freelist->free_list = buf->prev;
|
||||
buf = obj_stack_freelist->items;
|
||||
obj_stack_freelist->items = buf->prev;
|
||||
obj_stack_freelist->numfree--;
|
||||
}
|
||||
else {
|
||||
|
@ -47,8 +47,8 @@ _PyObjectStackChunk_Free(_PyObjectStackChunk *buf)
|
|||
if (obj_stack_freelist->numfree >= 0 &&
|
||||
obj_stack_freelist->numfree < _PyObjectStackChunk_MAXFREELIST)
|
||||
{
|
||||
buf->prev = obj_stack_freelist->free_list;
|
||||
obj_stack_freelist->free_list = buf;
|
||||
buf->prev = obj_stack_freelist->items;
|
||||
obj_stack_freelist->items = buf;
|
||||
obj_stack_freelist->numfree++;
|
||||
}
|
||||
else {
|
||||
|
@ -97,12 +97,12 @@ _PyObjectStackChunk_ClearFreeList(struct _Py_object_freelists *freelists, int is
|
|||
return;
|
||||
}
|
||||
|
||||
struct _Py_object_stack_freelist *state = &freelists->object_stacks;
|
||||
while (state->numfree > 0) {
|
||||
_PyObjectStackChunk *buf = state->free_list;
|
||||
state->free_list = buf->prev;
|
||||
state->numfree--;
|
||||
struct _Py_object_stack_freelist *freelist = &freelists->object_stacks;
|
||||
while (freelist->numfree > 0) {
|
||||
_PyObjectStackChunk *buf = freelist->items;
|
||||
freelist->items = buf->prev;
|
||||
freelist->numfree--;
|
||||
PyMem_RawFree(buf);
|
||||
}
|
||||
state->numfree = -1;
|
||||
freelist->numfree = -1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue