Commit 25f8180e authored by Lisandro Dalcin's avatar Lisandro Dalcin

get rid of string comparisons in classmethod utility code

parent 54b721d2
...@@ -588,8 +588,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -588,8 +588,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln('static char %s[] = "%s";' % ( code.putln('static char %s[] = "%s";' % (
env.doc_cname, escape_byte_string(docstr))) env.doc_cname, escape_byte_string(docstr)))
env.use_utility_code(streq_utility_code)
# XXX this is a mess # XXX this is a mess
for utility_code in PyrexTypes.c_int_from_py_function.specialize_list: for utility_code in PyrexTypes.c_int_from_py_function.specialize_list:
env.use_utility_code(utility_code) env.use_utility_code(utility_code)
...@@ -1556,6 +1554,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1556,6 +1554,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln("static void %s(void); /*proto*/" % Naming.fileinit_cname) code.putln("static void %s(void); /*proto*/" % Naming.fileinit_cname)
def generate_import_star(self, env, code): def generate_import_star(self, env, code):
env.use_utility_code(streq_utility_code)
code.putln() code.putln()
code.putln("char* %s_type_names[] = {" % Naming.import_star) code.putln("char* %s_type_names[] = {" % Naming.import_star)
for name, entry in env.entries.items(): for name, entry in env.entries.items():
......
...@@ -1583,8 +1583,14 @@ static PyObject* __Pyx_Method_ClassMethod(PyObject *method); /*proto*/ ...@@ -1583,8 +1583,14 @@ static PyObject* __Pyx_Method_ClassMethod(PyObject *method); /*proto*/
impl = """ impl = """
static PyObject* __Pyx_Method_ClassMethod(PyObject *method) { static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
/* It appears that PyMethodDescr_Type is not anywhere exposed in the Python/C API */ /* It appears that PyMethodDescr_Type is not anywhere exposed in the Python/C API */
/* if (!PyObject_TypeCheck(method, &PyMethodDescr_Type)) { */ static PyTypeObject *methoddescr_type = NULL;
if (__Pyx_StrEq(Py_TYPE(method)->tp_name, "method_descriptor")) { /* cdef classes */ if (methoddescr_type == NULL) {
PyObject *meth = __Pyx_GetAttrString((PyObject*)&PyList_Type, "append");
if (!meth) return NULL;
methoddescr_type = Py_TYPE(meth);
Py_DECREF(meth);
}
if (PyObject_TypeCheck(method, methoddescr_type)) { /* cdef classes */
PyMethodDescrObject *descr = (PyMethodDescrObject *)method; PyMethodDescrObject *descr = (PyMethodDescrObject *)method;
return PyDescr_NewClassMethod(descr->d_type, descr->d_method); return PyDescr_NewClassMethod(descr->d_type, descr->d_method);
} }
......
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