]> granicus.if.org Git - python/commitdiff
Minor bit of factoring-out common code.
authorRaymond Hettinger <python@rcn.com>
Tue, 7 Jul 2015 02:08:49 +0000 (19:08 -0700)
committerRaymond Hettinger <python@rcn.com>
Tue, 7 Jul 2015 02:08:49 +0000 (19:08 -0700)
Objects/setobject.c

index 383e7a41b2f4c0dc6e6a17d3ed040da05b31dba3..12f82f339862423bcea5867c1e889830b1b5c8bc 100644 (file)
@@ -1271,26 +1271,14 @@ set_intersection(PySetObject *so, PyObject *other)
 
     while ((key = PyIter_Next(it)) != NULL) {
         hash = PyObject_Hash(key);
-        if (hash == -1) {
-            Py_DECREF(it);
-            Py_DECREF(result);
-            Py_DECREF(key);
-            return NULL;
-        }
+        if (hash == -1)
+            goto error;
         rv = set_contains_entry(so, key, hash);
-        if (rv < 0) {
-            Py_DECREF(it);
-            Py_DECREF(result);
-            Py_DECREF(key);
-            return NULL;
-        }
+        if (rv < 0)
+            goto error;
         if (rv) {
-            if (set_add_entry(result, key, hash)) {
-                Py_DECREF(it);
-                Py_DECREF(result);
-                Py_DECREF(key);
-                return NULL;
-            }
+            if (set_add_entry(result, key, hash))
+                goto error;
         }
         Py_DECREF(key);
     }
@@ -1300,6 +1288,11 @@ set_intersection(PySetObject *so, PyObject *other)
         return NULL;
     }
     return (PyObject *)result;
+  error:
+    Py_DECREF(it);
+    Py_DECREF(result);
+    Py_DECREF(key);
+    return NULL;
 }
 
 static PyObject *