From 8839d75af18291e84ab7dda2144341becb45c4ab Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Wed, 24 Dec 2008 22:52:23 +0100 Subject: [PATCH] be more optimistic when parsing optional keywords: if (interned) string pointers are identical, we know it's the right type of object --- Cython/Compiler/Nodes.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) 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 -- 2.26.2