Commits

marcus  committed dc4e24e

Speeded up DoubleFromObj() C API (as recommended by Campell Barton)

  • Participants
  • Parent commits 0171925
  • Branches pgreloaded

Comments (0)

Files changed (1)

File src/base/basemod.c

 int
 DoubleFromObj (PyObject* obj, double* val)
 {
-    PyObject* floatobj;
     double tmp;
 
     if (!obj || !val)
         return 0;
     }
 
-    if (PyNumber_Check (obj))
-    {
-        if (!(floatobj = PyNumber_Float (obj)))
-            return 0;
-        tmp = PyFloat_AsDouble (floatobj);
-        Py_DECREF (floatobj);
-        if (tmp == -1 && PyErr_Occurred ())
-            return 0;
-        *val = tmp;
-        return 1;
-    }
-    return 0;
+    tmp = PyFloat_AsDouble (obj);
+    if (tmp == -1 && PyErr_Occurred ())
+        return 0;
+    *val = tmp;
+    return 1;
 }
 
 int