summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2020-04-17 09:13:37 +0200
committerStefan Behnel <stefan_ml@behnel.de>2020-04-17 10:16:06 +0200
commit765dd499ed9d16697b12b8c3eaec6d753223335b (patch)
tree507ce68ef86143254a2fefeb8507147a04b38781
parent8db370d57c18e52de19191859e12f85605039976 (diff)
downloadcython-765dd499ed9d16697b12b8c3eaec6d753223335b.tar.gz
Simplify some redundant code by calling the obvious helper function instead.
-rw-r--r--Cython/Utility/Optimize.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/Cython/Utility/Optimize.c b/Cython/Utility/Optimize.c
index 85ecf5359..a401aa26d 100644
--- a/Cython/Utility/Optimize.c
+++ b/Cython/Utility/Optimize.c
@@ -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)) {