Skip to content

Commit 12f4fdb

Browse files
committed
address review: remove make_array()
1 parent 3adb655 commit 12f4fdb

1 file changed

Lines changed: 2 additions & 43 deletions

File tree

‎Modules/arraymodule.c‎

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2168,47 +2168,6 @@ typecode_to_mformat_code(const char *typecode)
21682168
}
21692169
}
21702170

2171-
/* Forward declaration. */
2172-
static PyObject *array_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
2173-
2174-
/*
2175-
* Internal: This function wraps the array constructor--i.e., array_new()--to
2176-
* allow the creation of array objects from C code without having to deal
2177-
* directly the tuple argument of array_new(). The typecode argument is a
2178-
* string, like "i" or "f" for example, representing an array
2179-
* type code. The items argument is a bytes or a list object from which
2180-
* contains the initial value of the array.
2181-
*
2182-
* On success, this functions returns the array object created. Otherwise,
2183-
* NULL is returned to indicate a failure.
2184-
*/
2185-
static PyObject *
2186-
make_array(PyTypeObject *arraytype, const char *typecode, PyObject *items)
2187-
{
2188-
PyObject *new_args;
2189-
PyObject *array_obj;
2190-
PyObject *typecode_obj;
2191-
2192-
assert(arraytype != NULL);
2193-
assert(items != NULL);
2194-
2195-
typecode_obj = PyUnicode_FromString(typecode);
2196-
if (typecode_obj == NULL)
2197-
return NULL;
2198-
2199-
new_args = _PyTuple_FromPairSteal(typecode_obj, Py_NewRef(items));
2200-
if (new_args == NULL) {
2201-
return NULL;
2202-
}
2203-
2204-
array_obj = array_new(arraytype, new_args, NULL);
2205-
Py_DECREF(new_args);
2206-
if (array_obj == NULL)
2207-
return NULL;
2208-
2209-
return array_obj;
2210-
}
2211-
22122171
/*
22132172
* This functions is a special constructor used when unpickling an array. It
22142173
* provides a portable way to rebuild an array from its memory representation.
@@ -2275,7 +2234,7 @@ array__array_reconstructor_impl(PyObject *module, PyTypeObject *arraytype,
22752234
/* Fast path: No decoding has to be done. */
22762235
if (mformat_code == typecode_to_mformat_code(typecode) ||
22772236
mformat_code == UNKNOWN_FORMAT) {
2278-
return make_array(arraytype, typecode, items);
2237+
return array_new_impl(arraytype, typecode, items);
22792238
}
22802239

22812240
/* Slow path: Decode the byte string according to the given machine
@@ -2488,7 +2447,7 @@ array__array_reconstructor_impl(PyObject *module, PyTypeObject *arraytype,
24882447
return NULL;
24892448
}
24902449

2491-
result = make_array(arraytype, typecode, converted_items);
2450+
result = array_new_impl(arraytype, typecode, converted_items);
24922451
Py_DECREF(converted_items);
24932452
return result;
24942453
}

0 commit comments

Comments
 (0)