From: Stefan Behnel Date: Wed, 24 Dec 2008 21:52:23 +0000 (+0100) Subject: be more optimistic when parsing optional keywords: if (interned) string pointers... X-Git-Tag: 0.11-beta~81 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8839d75af18291e84ab7dda2144341becb45c4ab;p=cython.git be more optimistic when parsing optional keywords: if (interned) string pointers are identical, we know it's the right type of object --- diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 8cb8587e..3b5cb85f 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -4961,18 +4961,17 @@ static int __Pyx_ParseOptionalKeywords( PyObject*** first_kw_arg = argnames + num_pos_args; while (PyDict_Next(kwds, &pos, &key, &value)) { - #if PY_MAJOR_VERSION < 3 - if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) { - #else - if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) { - #endif - goto invalid_keyword_type; + name = first_kw_arg; + while (*name && (**name != key)) name++; + if (*name) { + values[name-argnames] = value; } else { - name = argnames; - while (*name && (**name != key)) name++; - if (*name) { - if (name < first_kw_arg) goto arg_passed_twice; - values[name-argnames] = value; + #if PY_MAJOR_VERSION < 3 + if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) { + #else + if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) { + #endif + goto invalid_keyword_type; } else { for (name = first_kw_arg; *name; name++) { #if PY_MAJOR_VERSION >= 3