[Zope3-checkins]
SVN: Zope3/branches/alienoid-adapter_lookup_coptimizations/src/zope/interface/_zope_adapter_lookup_coptimizations.c
Modified lookup to use 'emptystr' file level static variable
instead of
Ruslan Spivak
rspivak at nuxeo.com
Sun Aug 7 10:38:18 EDT 2005
Log message for revision 37770:
Modified lookup to use 'emptystr' file level static variable instead of
manually create it inside function.
Changed:
U Zope3/branches/alienoid-adapter_lookup_coptimizations/src/zope/interface/_zope_adapter_lookup_coptimizations.c
-=-
Modified: Zope3/branches/alienoid-adapter_lookup_coptimizations/src/zope/interface/_zope_adapter_lookup_coptimizations.c
===================================================================
--- Zope3/branches/alienoid-adapter_lookup_coptimizations/src/zope/interface/_zope_adapter_lookup_coptimizations.c 2005-08-07 13:21:29 UTC (rev 37769)
+++ Zope3/branches/alienoid-adapter_lookup_coptimizations/src/zope/interface/_zope_adapter_lookup_coptimizations.c 2005-08-07 14:38:18 UTC (rev 37770)
@@ -234,7 +234,7 @@
{
int i, j, k;
PyObject *required, *provided;
- PyObject *name = NULL;
+ PyObject *name = emptystr;
PyObject *_default = Py_None;
PyObject *surrogate, *byname, *value = NULL;
@@ -248,11 +248,6 @@
const int order = PySequence_Length(required);
- if (name == NULL)
- name = PyString_FromString("");
- else
- Py_INCREF(name);
-
if (order == 1) {
/* Simple adapter */
PyObject *req = PySequence_GetItem(required, 0);
@@ -293,18 +288,15 @@
value = _default;
} else {
Py_XDECREF(byname);
- Py_XDECREF(name);
Py_INCREF(_default);
return _default;
}
}
- Py_XDECREF(name);
Py_INCREF(value);
return value;
on_error:
- Py_XDECREF(name);
return NULL;
} else if (!order) {
@@ -312,23 +304,19 @@
byname = PyObject_CallMethodObjArgs(self->_null,
strget,
provided, NULL);
- if (byname == NULL) {
- Py_XDECREF(name);
+ if (byname == NULL)
return NULL;
- }
if (byname != Py_None) {
value = PyDict_GetItem(byname, name);
Py_XDECREF(byname);
if (value == NULL)
value = _default;
- Py_XDECREF(name);
Py_XINCREF(value);
return value;
}
Py_XDECREF(byname);
- Py_XDECREF(name);
Py_INCREF(_default);
return _default;
}
@@ -484,7 +472,6 @@
Py_XDECREF(surrogates);
Py_XDECREF(key);
Py_XDECREF(with);
- Py_XDECREF(name);
if (_default == NULL) {
Py_INCREF(Py_None);
return Py_None;
@@ -495,7 +482,6 @@
fail_req:
Py_DECREF(with);
fail_with:
- Py_XDECREF(name);
return NULL;
}
More information about the Zope3-Checkins
mailing list