Commit c0dded1d authored by Stefan Behnel's avatar Stefan Behnel

reduce code overhead in some utility functions

parent ab2454fe
...@@ -10,12 +10,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) { ...@@ -10,12 +10,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; /* this is just to have an accurate signature */ return Py_None; /* this is just to have an accurate signature */
} else { } else {
PyObject *r, *m; return PyObject_CallMethodObjArgs(L, PYIDENT("append"), x, NULL);
m = PyObject_GetAttr(L, PYIDENT("append"));
if (!m) return NULL;
r = PyObject_CallFunctionObjArgs(m, x, NULL);
Py_DECREF(m);
return r;
} }
} }
...@@ -289,12 +284,10 @@ static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObjec ...@@ -289,12 +284,10 @@ static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObjec
} }
Py_INCREF(value); Py_INCREF(value);
} else { } else {
PyObject *m; if (default_value == Py_None)
m = PyObject_GetAttr(d, PYIDENT("get")); default_value = NULL;
if (!m) return NULL; value = PyObject_CallMethodObjArgs(
value = PyObject_CallFunctionObjArgs(m, key, d, PYIDENT("get"), key, default_value, NULL);
(default_value == Py_None) ? NULL : default_value, NULL);
Py_DECREF(m);
} }
#endif #endif
return value; return value;
...@@ -330,11 +323,7 @@ static PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *d ...@@ -330,11 +323,7 @@ static PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *d
} }
Py_INCREF(value); Py_INCREF(value);
} else { } else {
PyObject *m; value = PyObject_CallMethodObjArgs(d, PYIDENT("setdefault"), key, default_value, NULL);
m = PyObject_GetAttr(d, PYIDENT("setdefault"));
if (!m) return NULL;
value = PyObject_CallFunctionObjArgs(m, key, default_value, NULL);
Py_DECREF(m);
} }
#endif #endif
return value; return 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