[Zope3-checkins] SVN: Zope3/branches/alienoid-adapter_lookup_coptimizations/src/zope/interface/_zope_adapter_lookup_coptimizations.c lookup1 code refactoring for speed improvement

Ruslan Spivak rspivak at nuxeo.com
Wed Aug 3 16:31:16 EDT 2005


Log message for revision 37687:
  lookup1 code refactoring for speed improvement

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-03 20:24:31 UTC (rev 37686)
+++ Zope3/branches/alienoid-adapter_lookup_coptimizations/src/zope/interface/_zope_adapter_lookup_coptimizations.c	2005-08-03 20:31:16 UTC (rev 37687)
@@ -31,6 +31,7 @@
 
 
 static PyObject *strget, *strisOrExtends, *str__sro__, *strindex, *Null;
+static PyObject *emptystr;
 
 static int
 AdapterLookup_init(AdapterLookup *self, PyObject *args, PyObject *keywds)
@@ -502,7 +503,7 @@
 AdapterLookup_lookup1(AdapterLookup *self, PyObject *args, PyObject *keywds)
 {
         PyObject *required, *provided;
-        PyObject *name = NULL;
+        PyObject *name = emptystr;
         PyObject *_default = Py_None;
         PyObject *required_list;
         PyObject *res;
@@ -515,22 +516,15 @@
                                          &name, &_default))
                 return NULL;
 
-        if (name == NULL)
-                name = PyString_FromString("");
-        else
-                Py_INCREF(name);
+        param_args = Py_BuildValue("[O]O", required, provided);
 
-        required_list = Py_BuildValue("[O]", required);
+        kw = keywds;
+        Py_XINCREF(kw);
 
-        param_args = Py_BuildValue("OO", required_list, provided);
-        kw = Py_BuildValue("{s:O,s:O}", "name", name, "default", _default);
-        Py_DECREF(required_list);
-
         res = AdapterLookup_lookup(self, param_args, kw);
 
-        Py_DECREF(kw);
+        Py_XDECREF(kw);
         Py_DECREF(param_args);
-        Py_XDECREF(name);
 
         return res;
 }
@@ -1132,6 +1126,8 @@
         DEFINE_STRING(index);
 #undef DEFINE_STRING
 
+        emptystr = PyString_FromString("");
+
         /* Initialize types: */
         AdapterLookupType.tp_new = PyType_GenericNew;
         if (PyType_Ready(&AdapterLookupType) < 0)



More information about the Zope3-Checkins mailing list