Skip to content

Commit 9ba3cd3

Browse files
committed
MNT: refactor stringdtype_setitem following marten's suggestion
1 parent 53a4e75 commit 9ba3cd3

File tree

1 file changed

+3
-11
lines changed
  • numpy/_core/src/multiarray/stringdtype

1 file changed

+3
-11
lines changed

numpy/_core/src/multiarray/stringdtype/dtype.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -317,24 +317,16 @@ stringdtype_setitem(PyArray_StringDTypeObject *descr, PyObject *obj, char **data
317317
{
318318
npy_packed_static_string *sdata = (npy_packed_static_string *)dataptr;
319319

320-
int na_cmp = 0;
321-
322320
// borrow reference
323321
PyObject *na_object = descr->na_object;
324322

325-
// Note there are two different na_object != NULL checks here.
326-
//
327-
// Do not refactor this!
328-
//
329323
// We need the result of the comparison after acquiring the allocator, but
330324
// cannot use functions requiring the GIL when the allocator is acquired,
331325
// so we do the comparison before acquiring the allocator.
332326

333-
if (na_object != NULL) {
334-
na_cmp = na_eq_cmp(obj, na_object);
335-
if (na_cmp == -1) {
336-
return -1;
337-
}
327+
int na_cmp = na_eq_cmp(obj, na_object);
328+
if (na_cmp == -1) {
329+
return -1;
338330
}
339331

340332
npy_string_allocator *allocator = NpyString_acquire_allocator(descr);

0 commit comments

Comments
 (0)