File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -33,37 +33,43 @@ typedef struct {
33
33
34
34
35
35
/* Use a free list, since we should normally only need one at a time */
36
+ #ifndef Py_GIL_DISABLED
36
37
#define NPY_LOOP_DATA_CACHE_SIZE 5
37
38
static int loop_data_num_cached = 0 ;
38
39
static legacy_array_method_auxdata * loop_data_cache [NPY_LOOP_DATA_CACHE_SIZE ];
39
-
40
+ #else
41
+ #define NPY_LOOP_DATA_CACHE_SIZE 0
42
+ #endif
40
43
41
44
static void
42
45
legacy_array_method_auxdata_free (NpyAuxData * data )
43
46
{
47
+ #if NPY_LOOP_DATA_CACHE_SIZE > 0
44
48
if (loop_data_num_cached < NPY_LOOP_DATA_CACHE_SIZE ) {
45
49
loop_data_cache [loop_data_num_cached ] = (
46
50
(legacy_array_method_auxdata * )data );
47
51
loop_data_num_cached ++ ;
48
52
}
49
- else {
53
+ else
54
+ #endif
55
+ {
50
56
PyMem_Free (data );
51
57
}
52
58
}
53
59
54
- #undef NPY_LOOP_DATA_CACHE_SIZE
55
-
56
-
57
60
NpyAuxData *
58
61
get_new_loop_data (
59
62
PyUFuncGenericFunction loop , void * user_data , int pyerr_check )
60
63
{
61
64
legacy_array_method_auxdata * data ;
65
+ #if NPY_LOOP_DATA_CACHE_SIZE > 0
62
66
if (NPY_LIKELY (loop_data_num_cached > 0 )) {
63
67
loop_data_num_cached -- ;
64
68
data = loop_data_cache [loop_data_num_cached ];
65
69
}
66
- else {
70
+ else
71
+ #endif
72
+ {
67
73
data = PyMem_Malloc (sizeof (legacy_array_method_auxdata ));
68
74
if (data == NULL ) {
69
75
return NULL ;
@@ -77,6 +83,7 @@ get_new_loop_data(
77
83
return (NpyAuxData * )data ;
78
84
}
79
85
86
+ #undef NPY_LOOP_DATA_CACHE_SIZE
80
87
81
88
/*
82
89
* This is a thin wrapper around the legacy loop signature.
You can’t perform that action at this time.
0 commit comments