Mercurial > cpython-lru_cache-weakref
diff Objects/setobject.c @ 64121:2a4ceebdfcfb 3.1
Merged revisions 84146-84147,84150 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r84146 | antoine.pitrou | 2010-08-17 19:55:07 +0200 (mar., 17 août 2010) | 4 lines
Issue #9612: The set object is now 64-bit clean under Windows.
........
r84147 | antoine.pitrou | 2010-08-17 20:30:06 +0200 (mar., 17 août 2010) | 3 lines
Fix <deque iterator>.__length_hint__() under 64-bit Windows.
........
r84150 | antoine.pitrou | 2010-08-17 21:33:30 +0200 (mar., 17 août 2010) | 3 lines
Clean some 64-bit issues. Also, always spell "ssize_t" "Py_ssize_t".
........
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Tue, 17 Aug 2010 19:39:39 +0000 |
| parents | fa6314b141dc |
| children | 57657393ceaf 3c9232a684ae |
line wrap: on
line diff
--- a/Objects/setobject.c Tue Aug 17 08:41:48 2010 +0000 +++ b/Objects/setobject.c Tue Aug 17 19:39:39 2010 +0000 @@ -349,7 +349,7 @@ } else { /* ACTIVE */ --i; - set_insert_clean(so, entry->key, entry->hash); + set_insert_clean(so, entry->key, (long) entry->hash); } } @@ -368,7 +368,7 @@ assert(so->fill <= so->mask); /* at least one empty slot */ n_used = so->used; Py_INCREF(entry->key); - if (set_insert_key(so, entry->key, entry->hash) == -1) { + if (set_insert_key(so, entry->key, (long) entry->hash) == -1) { Py_DECREF(entry->key); return -1; } @@ -409,7 +409,7 @@ { register setentry *entry; PyObject *old_key; - entry = (so->lookup)(so, oldentry->key, oldentry->hash); + entry = (so->lookup)(so, oldentry->key, (long) oldentry->hash); if (entry == NULL) return -1; if (entry->key == NULL || entry->key == dummy) @@ -660,7 +660,7 @@ if (entry->key != NULL && entry->key != dummy) { Py_INCREF(entry->key); - if (set_insert_key(so, entry->key, entry->hash) == -1) { + if (set_insert_key(so, entry->key, (long) entry->hash) == -1) { Py_DECREF(entry->key); return -1; } @@ -694,7 +694,7 @@ PyObject *key; setentry *lu_entry; - lu_entry = (so->lookup)(so, entry->key, entry->hash); + lu_entry = (so->lookup)(so, entry->key, (long) entry->hash); if (lu_entry == NULL) return -1; key = lu_entry->key; @@ -769,14 +769,14 @@ if (so->hash != -1) return so->hash; - hash *= PySet_GET_SIZE(self) + 1; + hash *= (long) PySet_GET_SIZE(self) + 1; while (set_next(so, &pos, &entry)) { /* Work to increase the bit dispersion for closely spaced hash values. The is important because some use cases have many combinations of a small number of elements with nearby hashes so that many distinct combinations collapse to only a handful of distinct hash values. */ - h = entry->hash; + h = (long) entry->hash; hash ^= (h ^ (h << 16) ^ 89869747L) * 3644798167u; } hash = hash * 69069L + 907133923L; @@ -816,7 +816,7 @@ Py_ssize_t len = 0; if (si->si_set != NULL && si->si_used == si->si_set->used) len = si->len; - return PyLong_FromLong(len); + return PyLong_FromSsize_t(len); } PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it))."); @@ -1547,7 +1547,7 @@ setentry entrycopy; entrycopy.hash = entry->hash; entrycopy.key = entry->key; - if (!_PyDict_Contains(other, entry->key, entry->hash)) { + if (!_PyDict_Contains(other, entry->key, (long) entry->hash)) { if (set_add_entry((PySetObject *)result, &entrycopy) == -1) { Py_DECREF(result); return NULL; @@ -2309,7 +2309,7 @@ if (set_next((PySetObject *)set, pos, &entry) == 0) return 0; *key = entry->key; - *hash = entry->hash; + *hash = (long) entry->hash; return 1; }
