8000 MAINT: document minimum dim cache size == 2 · numpy/numpy@c114169 · GitHub
[go: up one dir, main page]

Skip to content

Commit c114169

Browse files
committed
MAINT: document minimum dim cache size == 2
Remove unlikely, as it is being used now more it may not be correct anymore.
1 parent 5a08e20 commit c114169

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

numpy/core/src/multiarray/alloc.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,11 @@ npy_free_cache(void * p, npy_uintp sz)
126126
NPY_NO_EXPORT void *
127127
npy_alloc_cache_dim(npy_uintp sz)
128128
{
129-
/* dims + strides */
130-
if (NPY_UNLIKELY(sz < 2)) {
129+
/*
130+
* make sure any temporary allocation can be used for array metadata which
131+
* uses one memory block for both dimensions and strides
132+
*/
133+
if (sz < 2) {
131134
sz = 2;
132135
}
133136
return _npy_alloc_cache(sz, sizeof(npy_intp), NBUCKETS_DIM, dimcache,
@@ -137,8 +140,8 @@ npy_alloc_cache_dim(npy_uintp sz)
137140
NPY_NO_EXPORT void
138141
npy_free_cache_dim(void * p, npy_uintp sz)
139142
{
140-
/* dims + strides */
141-
if (NPY_UNLIKELY(sz < 2)) {
143+
/* see npy_alloc_cache_dim */
144+
if (sz < 2) {
142145
sz = 2;
143146
}
144147
_npy_free_cache(p, sz, NBUCKETS_DIM, dimcache,

0 commit comments

Comments
 (0)
0