[pypy-commit] pypy rpython-hash: Tweaks & comments
arigo
pypy.commits at gmail.com
Fri Jan 27 03:00:21 EST 2017
Author: Armin Rigo <arigo at tunes.org>
Branch: rpython-hash
Changeset: r89795:40b971b7a0c7
Date: 2017-01-27 08:59 +0100
http://bitbucket.org/pypy/pypy/changeset/40b971b7a0c7/
Log: Tweaks & comments
diff --git a/rpython/rtyper/lltypesystem/rordereddict.py b/rpython/rtyper/lltypesystem/rordereddict.py
--- a/rpython/rtyper/lltypesystem/rordereddict.py
+++ b/rpython/rtyper/lltypesystem/rordereddict.py
@@ -539,6 +539,10 @@
elif fun == FUNC_LONG:
return ll_dict_store_clean(d, hash, i, TYPE_LONG)
elif fun == FUNC_NO_INDEX:
+ # NB. this case might be reachable or not, but I didn't manage
+ # to get here. Maybe it is not actually reachable right now
+ # but it depends on details. Better keep it written down
+ # just in case the details change later.
ll_dict_create_index(d)
# then, retry
else:
@@ -903,12 +907,35 @@
entries = d.entries
i = 0
ibound = d.num_ever_used_items
- while i < ibound:
- if entries.valid(i):
- hash = entries.hash(i)
- ll_call_insert_clean_function(d, hash, i)
- i += 1
- #old_entries.delete() XXXX!
+ #
+ # Write four loops, moving the check for the value of 'fun' out of
+ # the loops. A small speed-up, it also avoids the (unreachable)
+ # recursive call from here to ll_call_insert_clean_function() to
+ # ll_dict_create_index() back to here.
+ fun = d.lookup_function_no # == lookup_function_no & FUNC_MASK
+ if fun == FUNC_BYTE:
+ while i < ibound:
+ if entries.valid(i):
+ ll_dict_store_clean(d, entries.hash(i), i, TYPE_BYTE)
+ i += 1
+ elif fun == FUNC_SHORT:
+ while i < ibound:
+ if entries.valid(i):
+ ll_dict_store_clean(d, entries.hash(i), i, TYPE_SHORT)
+ i += 1
+ elif IS_64BIT and fun == FUNC_INT:
+ while i < ibound:
+ if entries.valid(i):
+ ll_dict_store_clean(d, entries.hash(i), i, TYPE_INT)
+ i += 1
+ elif fun == FUNC_LONG:
+ while i < ibound:
+ if entries.valid(i):
+ ll_dict_store_clean(d, entries.hash(i), i, TYPE_LONG)
+ i += 1
+ else:
+ assert False
+
# ------- a port of CPython's dictobject.c's lookdict implementation -------
PERTURB_SHIFT = 5
More information about the pypy-commit
mailing list