be more optimistic when parsing optional keywords: if (interned) string pointers...
authorStefan Behnel <scoder@users.berlios.de>
Wed, 24 Dec 2008 21:52:23 +0000 (22:52 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Wed, 24 Dec 2008 21:52:23 +0000 (22:52 +0100)
Cython/Compiler/Nodes.py

index 8cb8587ebbf04867a843ba3590a6c61dc8a78395..3b5cb85f96eef494a0c9963dffd48e6bc302304f 100644 (file)
@@ -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