[Python-checkins] python/nondist/sandbox/set setobject.c,1.3,1.4
rhettinger@users.sourceforge.net
rhettinger at users.sourceforge.net
Sat Jul 30 16:22:12 CEST 2005
Update of /cvsroot/python/python/nondist/sandbox/set
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3511
Modified Files:
setobject.c
Log Message:
Simplify code for symmetric_differences.
Index: setobject.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/set/setobject.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- setobject.c 29 Jul 2005 19:03:00 -0000 1.3
+++ setobject.c 30 Jul 2005 14:22:10 -0000 1.4
@@ -1258,46 +1258,17 @@
static PyObject *
set_symmetric_difference(PySetObject *so, PyObject *other)
{
- PyObject *rv, *key;
- PySetObject *result, *otherset;
- int pos = 0;
-
- if (!PyAnySet_Check(other)) {
- otherset = (PySetObject *)make_new_set(so->ob_type, other);
- if (otherset == NULL)
- return NULL;
- rv = set_symmetric_difference_update(otherset, (PyObject *)so);
- if (rv == NULL)
- return NULL;
- Py_DECREF(rv);
- return (PyObject *)otherset;
- }
+ PyObject *rv;
+ PySetObject *otherset;
- result = (PySetObject *)make_new_set(so->ob_type, NULL);
- if (result == NULL)
+ otherset = (PySetObject *)make_new_set(so->ob_type, other);
+ if (otherset == NULL)
return NULL;
-
- otherset = (PySetObject *)other;
- while (set_next_internal(otherset, &pos, &key)) {
- if (!set_contains_internal(so, key)) {
- if (set_add_internal(result, key) == -1) {
- Py_DECREF(result);
- return NULL;
- }
- }
- }
-
- pos = 0;
- while (set_next_internal(so, &pos, &key)) {
- if (!set_contains_internal(otherset, key)) {
- if (set_add_internal(result, key) == -1) {
- Py_DECREF(result);
- return NULL;
- }
- }
- }
-
- return (PyObject *)result;
+ rv = set_symmetric_difference_update(otherset, (PyObject *)so);
+ if (rv == NULL)
+ return NULL;
+ Py_DECREF(rv);
+ return (PyObject *)otherset;
}
PyDoc_STRVAR(symmetric_difference_doc,
More information about the Python-checkins
mailing list