diff options
author | Raymond Hettinger <python@rcn.com> | 2015-07-07 02:08:49 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2015-07-07 02:08:49 (GMT) |
commit | 11ce8e6c37c9f6b14ccac8abfe26d4c5e8313f5c (patch) | |
tree | c4fc8eb3ab141ad0f50c07010809556b5633075c /Objects/setobject.c | |
parent | 3dbc11cadd0aead3ee6d4d06fc3bf7309c6ce6a7 (diff) | |
download | cpython-11ce8e6c37c9f6b14ccac8abfe26d4c5e8313f5c.zip cpython-11ce8e6c37c9f6b14ccac8abfe26d4c5e8313f5c.tar.gz cpython-11ce8e6c37c9f6b14ccac8abfe26d4c5e8313f5c.tar.bz2 |
Minor bit of factoring-out common code.
Diffstat (limited to 'Objects/setobject.c')
-rw-r--r-- | Objects/setobject.c | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/Objects/setobject.c b/Objects/setobject.c index 383e7a4..12f82f3 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -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 * |