Author: Alex Gaynor <[email protected]>
Branch:
Changeset: r45204:6bca4ed0f817
Date: 2011-06-30 17:02 -0700
http://bitbucket.org/pypy/pypy/changeset/6bca4ed0f817/
Log: merged upstream
diff --git a/pypy/rpython/lltypesystem/rdict.py
b/pypy/rpython/lltypesystem/rdict.py
--- a/pypy/rpython/lltypesystem/rdict.py
+++ b/pypy/rpython/lltypesystem/rdict.py
@@ -845,11 +845,13 @@
POPITEMINDEX = lltype.Struct('PopItemIndex', ('nextindex', lltype.Signed))
global_popitem_index = lltype.malloc(POPITEMINDEX, zero=True, immortal=True)
-def ll_popitem(ELEM, dic):
+def _ll_getnextitem(dic):
entries = dic.entries
ENTRY = lltype.typeOf(entries).TO.OF
dmask = len(entries) - 1
if hasattr(ENTRY, 'f_hash'):
+ if entries.valid(0):
+ return 0
base = entries[0].f_hash
else:
base = global_popitem_index.nextindex
@@ -865,7 +867,11 @@
entries[0].f_hash = base + counter
else:
global_popitem_index.nextindex = base + counter
- entry = entries[i]
+ return i
+
+def ll_popitem(ELEM, dic):
+ i = _ll_getnextitem(dic)
+ entry = dic.entries[i]
r = lltype.malloc(ELEM.TO)
r.item0 = recast(ELEM.TO.item0, entry.key)
r.item1 = recast(ELEM.TO.item1, entry.value)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit