diff options
author | Raymond Hettinger <python@rcn.com> | 2007-03-20 21:27:24 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2007-03-20 21:27:24 (GMT) |
commit | 0bbbfc4c0b0cf84a23d2644080d09fb8af5324d2 (patch) | |
tree | f298dd7e7f9cd0ebb5e98a5bd33cd1046bc1dba5 /Objects/setobject.c | |
parent | ce55e21c70068315e128980848f86d1d471fc41c (diff) | |
download | cpython-0bbbfc4c0b0cf84a23d2644080d09fb8af5324d2.zip cpython-0bbbfc4c0b0cf84a23d2644080d09fb8af5324d2.tar.gz cpython-0bbbfc4c0b0cf84a23d2644080d09fb8af5324d2.tar.bz2 |
Extend work on rev 52962 and 53829 eliminating redundant PyObject_Hash() calls and fixing set/dict interoperability.
Diffstat (limited to 'Objects/setobject.c')
-rw-r--r-- | Objects/setobject.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/Objects/setobject.c b/Objects/setobject.c index 07ba996..a896d93 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -2137,7 +2137,7 @@ PySet_Add(PyObject *set, PyObject *key) } int -_PySet_Next(PyObject *set, Py_ssize_t *pos, PyObject **entry) +_PySet_Next(PyObject *set, Py_ssize_t *pos, PyObject **key) { setentry *entry_ptr; @@ -2147,7 +2147,23 @@ _PySet_Next(PyObject *set, Py_ssize_t *pos, PyObject **entry) } if (set_next((PySetObject *)set, pos, &entry_ptr) == 0) return 0; - *entry = entry_ptr->key; + *key = entry_ptr->key; + return 1; +} + +int +_PySet_NextEntry(PyObject *set, Py_ssize_t *pos, PyObject **key, long *hash) +{ + setentry *entry; + + if (!PyAnySet_Check(set)) { + PyErr_BadInternalCall(); + return -1; + } + if (set_next((PySetObject *)set, pos, &entry) == 0) + return 0; + *key = entry->key; + *hash = entry->hash; return 1; } |