]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-111968: Unify freelist naming schema to Eric's suggestion (gh-114581)
authorDonghee Na <donghee.na@python.org>
Fri, 26 Jan 2024 15:25:16 +0000 (00:25 +0900)
committerGitHub <noreply@github.com>
Fri, 26 Jan 2024 15:25:16 +0000 (00:25 +0900)
Include/internal/pycore_freelist.h
Objects/floatobject.c
Objects/genobject.c
Objects/listobject.c
Objects/sliceobject.c
Objects/tupleobject.c
Python/context.c
Python/object_stack.c

index dfb12839affedfcdd48aa4f82207c33d3904cc90..b91d2bc066b783b546133a816efcc00d76466a20 100644 (file)
@@ -103,13 +103,13 @@ struct _Py_object_stack_state {
 };
 
 typedef struct _Py_freelist_state {
-    struct _Py_float_state float_state;
-    struct _Py_tuple_state tuple_state;
-    struct _Py_list_state list_state;
-    struct _Py_slice_state slice_state;
-    struct _Py_context_state context_state;
-    struct _Py_async_gen_state async_gen_state;
-    struct _Py_object_stack_state object_stack_state;
+    struct _Py_float_state floats;
+    struct _Py_tuple_state tuples;
+    struct _Py_list_state lists;
+    struct _Py_slice_state slices;
+    struct _Py_context_state contexts;
+    struct _Py_async_gen_state async_gens;
+    struct _Py_object_stack_state object_stacks;
 } _PyFreeListState;
 
 #ifdef __cplusplus
index 912c450a5e1055c5652579e100f29357cc288527..b7611d5f96ac3be4ef1e13aaab9fb12e36423e43 100644 (file)
@@ -32,7 +32,7 @@ get_float_state(void)
 {
     _PyFreeListState *state = _PyFreeListState_GET();
     assert(state != NULL);
-    return &state->float_state;
+    return &state->floats;
 }
 #endif
 
@@ -1993,7 +1993,7 @@ void
 _PyFloat_ClearFreeList(_PyFreeListState *freelist_state, int is_finalization)
 {
 #ifdef WITH_FREELISTS
-    struct _Py_float_state *state = &freelist_state->float_state;
+    struct _Py_float_state *state = &freelist_state->floats;
     PyFloatObject *f = state->free_list;
     while (f != NULL) {
         PyFloatObject *next = (PyFloatObject*) Py_TYPE(f);
index e9aeb7ab9a9fa836c6cc036549f8263427395488..f47197330fdd8018d33ee6ca74882f08070b217b 100644 (file)
@@ -1633,7 +1633,7 @@ static struct _Py_async_gen_state *
 get_async_gen_state(void)
 {
     _PyFreeListState *state = _PyFreeListState_GET();
-    return &state->async_gen_state;
+    return &state->async_gens;
 }
 #endif
 
@@ -1659,7 +1659,7 @@ void
 _PyAsyncGen_ClearFreeLists(_PyFreeListState *freelist_state, int is_finalization)
 {
 #ifdef WITH_FREELISTS
-    struct _Py_async_gen_state *state = &freelist_state->async_gen_state;
+    struct _Py_async_gen_state *state = &freelist_state->async_gens;
 
     while (state->value_numfree > 0) {
         _PyAsyncGenWrappedValue *o;
index 401d1026133f4e17957fefe102765d01fd7f72f8..1e885f9cb80c4ce1e4cb7299c2f30fdadf76b78f 100644 (file)
@@ -26,7 +26,7 @@ get_list_state(void)
 {
     _PyFreeListState *state = _PyFreeListState_GET();
     assert(state != NULL);
-    return &state->list_state;
+    return &state->lists;
 }
 #endif
 
@@ -124,7 +124,7 @@ void
 _PyList_ClearFreeList(_PyFreeListState *freelist_state, int is_finalization)
 {
 #ifdef WITH_FREELISTS
-    struct _Py_list_state *state = &freelist_state->list_state;
+    struct _Py_list_state *state = &freelist_state->lists;
     while (state->numfree > 0) {
         PyListObject *op = state->free_list[--state->numfree];
         assert(PyList_CheckExact(op));
index 440c1da30620c389d1d0afde51651436ccec9be1..8b9d6bbfd858b75964931abaef090445a0616acd 100644 (file)
@@ -106,9 +106,9 @@ PyObject _Py_EllipsisObject = _PyObject_HEAD_INIT(&PyEllipsis_Type);
 void _PySlice_ClearCache(_PyFreeListState *state)
 {
 #ifdef WITH_FREELISTS
-    PySliceObject *obj = state->slice_state.slice_cache;
+    PySliceObject *obj = state->slices.slice_cache;
     if (obj != NULL) {
-        state->slice_state.slice_cache = NULL;
+        state->slices.slice_cache = NULL;
         PyObject_GC_Del(obj);
     }
 #endif
@@ -132,9 +132,9 @@ _PyBuildSlice_Consume2(PyObject *start, PyObject *stop, PyObject *step)
     PySliceObject *obj;
 #ifdef WITH_FREELISTS
     _PyFreeListState *state = _PyFreeListState_GET();
-    if (state->slice_state.slice_cache != NULL) {
-        obj = state->slice_state.slice_cache;
-        state->slice_state.slice_cache = NULL;
+    if (state->slices.slice_cache != NULL) {
+        obj = state->slices.slice_cache;
+        state->slices.slice_cache = NULL;
         _Py_NewReference((PyObject *)obj);
     }
     else
@@ -370,8 +370,8 @@ slice_dealloc(PySliceObject *r)
     Py_DECREF(r->stop);
 #ifdef WITH_FREELISTS
     _PyFreeListState *state = _PyFreeListState_GET();
-    if (state->slice_state.slice_cache == NULL) {
-        state->slice_state.slice_cache = r;
+    if (state->slices.slice_cache == NULL) {
+        state->slices.slice_cache = r;
     }
     else
 #endif
index e1b8e4004c616386619eabac2bcd366661423aef..b9bf6cd48f612927b847128dbd6b74d70f47519c 100644 (file)
@@ -1125,7 +1125,7 @@ tuple_iter(PyObject *seq)
  * freelists *
  *************/
 
-#define STATE (state->tuple_state)
+#define STATE (state->tuples)
 #define FREELIST_FINALIZED (STATE.numfree[0] < 0)
 
 static inline PyTupleObject *
index 1e90811c374ec63bba0691cd2688447c1dc3c6c7..294485e5b407dfeadc2cb53821fbbf475af431f8 100644 (file)
@@ -69,7 +69,7 @@ static struct _Py_context_state *
 get_context_state(void)
 {
     _PyFreeListState *state = _PyFreeListState_GET();
-    return &state->context_state;
+    return &state->contexts;
 }
 #endif
 
@@ -1270,7 +1270,7 @@ void
 _PyContext_ClearFreeList(_PyFreeListState *freelist_state, int is_finalization)
 {
 #ifdef WITH_FREELISTS
-    struct _Py_context_state *state = &freelist_state->context_state;
+    struct _Py_context_state *state = &freelist_state->contexts;
     for (; state->numfree > 0; state->numfree--) {
         PyContext *ctx = state->freelist;
         state->freelist = (PyContext *)ctx->ctx_weakreflist;
index 66b37bcbb44475894d3f3cc057235480d5066c43..8544892eb71dcb62eec024a7e636c7895e7bdf02 100644 (file)
@@ -12,7 +12,7 @@ static struct _Py_object_stack_state *
 get_state(void)
 {
     _PyFreeListState *state = _PyFreeListState_GET();
-    return &state->object_stack_state;
+    return &state->object_stacks;
 }
 
 _PyObjectStackChunk *
@@ -76,7 +76,7 @@ _PyObjectStackChunk_ClearFreeList(_PyFreeListState *free_lists, int is_finalizat
         return;
     }
 
-    struct _Py_object_stack_state *state = &free_lists->object_stack_state;
+    struct _Py_object_stack_state *state = &free_lists->object_stacks;
     while (state->numfree > 0) {
         _PyObjectStackChunk *buf = state->free_list;
         state->free_list = buf->prev;