Use METH_O where possible (two functions). This does not lead to real

performance changes since the affected functions are not expected to be
used frequently, but reduces the volume of code.
This commit is contained in:
Fred Drake 2001-08-16 14:11:30 +00:00
parent 1690409243
commit 7fdc0a1835
1 changed files with 24 additions and 29 deletions

View File

@ -504,12 +504,10 @@ static char weakref_getweakrefcount__doc__[] =
"to 'object'.";
static PyObject *
weakref_getweakrefcount(PyObject *self, PyObject *args)
weakref_getweakrefcount(PyObject *self, PyObject *object)
{
PyObject *result = NULL;
PyObject *object;
if (PyArg_ParseTuple(args, "O:getweakrefcount", &object)) {
if (PyType_SUPPORTS_WEAKREFS(object->ob_type)) {
PyWeakReference **list = GET_WEAKREFS_LISTPTR(object);
@ -517,7 +515,7 @@ weakref_getweakrefcount(PyObject *self, PyObject *args)
}
else
result = PyInt_FromLong(0);
}
return result;
}
@ -527,12 +525,10 @@ static char weakref_getweakrefs__doc__[] =
"that point to 'object'.";
static PyObject *
weakref_getweakrefs(PyObject *self, PyObject *args)
weakref_getweakrefs(PyObject *self, PyObject *object)
{
PyObject *result = NULL;
PyObject *object;
if (PyArg_ParseTuple(args, "O:getweakrefs", &object)) {
if (PyType_SUPPORTS_WEAKREFS(object->ob_type)) {
PyWeakReference **list = GET_WEAKREFS_LISTPTR(object);
long count = getweakrefcount(*list);
@ -551,7 +547,6 @@ weakref_getweakrefs(PyObject *self, PyObject *args)
else {
result = PyList_New(0);
}
}
return result;
}
@ -796,9 +791,9 @@ cleanup_helper(PyObject *object)
static PyMethodDef
weakref_functions[] = {
{"getweakrefcount", weakref_getweakrefcount, METH_VARARGS,
{"getweakrefcount", weakref_getweakrefcount, METH_O,
weakref_getweakrefcount__doc__},
{"getweakrefs", weakref_getweakrefs, METH_VARARGS,
{"getweakrefs", weakref_getweakrefs, METH_O,
weakref_getweakrefs__doc__},
{"proxy", weakref_proxy, METH_VARARGS,
weakref_proxy__doc__},