Commit 765dd499 authored by Stefan Behnel's avatar Stefan Behnel

Simplify some redundant code by calling the obvious helper function instead.

parent 8db370d5
......@@ -596,11 +596,14 @@ static double __Pyx__PyObject_AsDouble(PyObject* obj); /* proto */
#endif
/////////////// pyobject_as_double ///////////////
//@requires: ObjectHandling.c::PyObjectCallOneArg
static double __Pyx__PyObject_AsDouble(PyObject* obj) {
PyObject* float_value;
#if !CYTHON_USE_TYPE_SLOTS
float_value = PyNumber_Float(obj); if ((0)) goto bad;
// avoid "unused" warnings
(void)__Pyx_PyObject_CallOneArg;
#else
PyNumberMethods *nb = Py_TYPE(obj)->tp_as_number;
if (likely(nb) && likely(nb->nb_float)) {
......@@ -619,12 +622,7 @@ static double __Pyx__PyObject_AsDouble(PyObject* obj) {
float_value = PyFloat_FromString(obj, 0);
#endif
} else {
PyObject* args = PyTuple_New(1);
if (unlikely(!args)) goto bad;
PyTuple_SET_ITEM(args, 0, obj);
float_value = PyObject_Call((PyObject*)&PyFloat_Type, args, 0);
PyTuple_SET_ITEM(args, 0, 0);
Py_DECREF(args);
float_value = __Pyx_PyObject_CallOneArg((PyObject*)&PyFloat_Type, obj);
}
#endif
if (likely(float_value)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment