summaryrefslogtreecommitdiff
path: root/Objects
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2005-08-06 18:57:13 +0000
committerRaymond Hettinger <python@rcn.com>2005-08-06 18:57:13 +0000
commitd229e73dc44f841bc4c23de3048a6d916ad93dfe (patch)
tree114d818b234cd03d2ba326a41f30313a2302584a /Objects
parent5977004183e4476ba66ace9ce2894db888f96cc7 (diff)
downloadcpython-d229e73dc44f841bc4c23de3048a6d916ad93dfe.tar.gz
* Removed checked_error flag which no longer provides any benefit.
* Have issubset() control its own loop instead of using set_next_internal().
Diffstat (limited to 'Objects')
-rw-r--r--Objects/setobject.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/Objects/setobject.c b/Objects/setobject.c
index c46df83b20..771d512b58 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -49,7 +49,6 @@ set_lookkey(PySetObject *so, PyObject *key, register long hash)
setentry *table = so->table;
register setentry *entry;
register int restore_error;
- register int checked_error;
register int cmp;
PyObject *err_type, *err_value, *err_tb;
PyObject *startkey;
@@ -59,13 +58,11 @@ set_lookkey(PySetObject *so, PyObject *key, register long hash)
if (entry->key == NULL || entry->key == key)
return entry;
- restore_error = checked_error = 0;
+ restore_error = 0;
if (entry->key == dummy)
freeslot = entry;
else {
if (entry->hash == hash) {
- /* error can't have been checked yet */
- checked_error = 1;
if (_PyErr_OCCURRED()) {
restore_error = 1;
PyErr_Fetch(&err_type, &err_value, &err_tb);
@@ -102,13 +99,10 @@ set_lookkey(PySetObject *so, PyObject *key, register long hash)
if (entry->key == key)
break;
if (entry->hash == hash && entry->key != dummy) {
- if (!checked_error) {
- checked_error = 1;
- if (_PyErr_OCCURRED()) {
- restore_error = 1;
- PyErr_Fetch(&err_type, &err_value,
- &err_tb);
- }
+ if (_PyErr_OCCURRED()) {
+ restore_error = 1;
+ PyErr_Fetch(&err_type, &err_value,
+ &err_tb);
}
startkey = entry->key;
cmp = PyObject_RichCompareBool(startkey, key, Py_EQ);
@@ -1267,8 +1261,8 @@ static PyObject *
set_issubset(PySetObject *so, PyObject *other)
{
PyObject *tmp, *result;
- PyObject *key;
- int pos = 0;
+ register setentry *entry;
+ register int i;
if (!PyAnySet_Check(other)) {
tmp = make_new_set(&PySet_Type, other);
@@ -1281,8 +1275,11 @@ set_issubset(PySetObject *so, PyObject *other)
if (set_len((PyObject *)so) > set_len(other))
Py_RETURN_FALSE;
- while (set_next_internal(so, &pos, &key)) {
- if (!set_contains_internal((PySetObject *)other, key))
+ entry = &so->table[0];
+ for (i=so->used ; i ; entry++, i--) {
+ while (entry->key == NULL || entry->key==dummy)
+ entry++;
+ if (!set_contains_internal((PySetObject *)other, entry->key))
Py_RETURN_FALSE;
}
Py_RETURN_TRUE;