@@ -105,16 +105,20 @@ PyObject _Py_EllipsisObject = _PyObject_HEAD_INIT(&PyEllipsis_Type);
105
105
106
106
void _PySlice_ClearCache (_PyFreeListState * state )
107
107
{
108
+ #ifdef WITH_FREELISTS
108
109
PySliceObject * obj = state -> slice_state .slice_cache ;
109
110
if (obj != NULL ) {
110
111
state -> slice_state .slice_cache = NULL ;
111
112
PyObject_GC_Del (obj );
112
113
}
114
+ #endif
113
115
}
114
116
115
117
void _PySlice_Fini (_PyFreeListState * state )
116
118
{
119
+ #ifdef WITH_FREELISTS
117
120
_PySlice_ClearCache (state );
121
+ #endif
118
122
}
119
123
120
124
/* start, stop, and step are python objects with None indicating no
@@ -125,15 +129,17 @@ static PySliceObject *
125
129
_PyBuildSlice_Consume2 (PyObject * start , PyObject * stop , PyObject * step )
126
130
{
127
131
assert (start != NULL && stop != NULL && step != NULL );
128
-
129
- _PyFreeListState * state = _PyFreeListState_GET ();
130
132
PySliceObject * obj ;
133
+ #ifdef WITH_FREELISTS
134
+ _PyFreeListState * state = _PyFreeListState_GET ();
131
135
if (state -> slice_state .slice_cache != NULL ) {
132
136
obj = state -> slice_state .slice_cache ;
133
137
state -> slice_state .slice_cache = NULL ;
134
138
_Py_NewReference ((PyObject * )obj );
135
139
}
136
- else {
140
+ else
141
+ #endif
142
+ {
137
143
obj = PyObject_GC_New (PySliceObject , & PySlice_Type );
138
144
if (obj == NULL ) {
139
145
goto error ;
@@ -358,15 +364,18 @@ Create a slice object. This is used for extended slicing (e.g. a[0:10:2]).");
358
364
static void
359
365
slice_dealloc (PySliceObject * r )
360
366
{
361
- _PyFreeListState * state = _PyFreeListState_GET ();
362
367
_PyObject_GC_UNTRACK (r );
363
368
Py_DECREF (r -> step );
364
369
Py_DECREF (r -> start );
365
370
Py_DECREF (r -> stop );
371
+ #ifdef WITH_FREELISTS
372
+ _PyFreeListState * state = _PyFreeListState_GET ();
366
373
if (state -> slice_state .slice_cache == NULL ) {
367
374
state -> slice_state .slice_cache = r ;
368
375
}
369
- else {
376
+ else
377
+ #endif
378
+ {
370
379
PyObject_GC_Del (r );
371
380
}
372
381
}
0 commit comments