[pypy-svn] r32141 - pypy/branch/rdict-index-based/pypy/rpython/lltypesystem

mwh at codespeak.net mwh at codespeak.net
Mon Sep 11 11:59:22 CEST 2006


Author: mwh
Date: Mon Sep 11 11:59:21 2006
New Revision: 32141

Modified:
   pypy/branch/rdict-index-based/pypy/rpython/lltypesystem/rdict.py
Log:
obscure: if (something that gets merged with r_uint) >= 0: isn't useful


Modified: pypy/branch/rdict-index-based/pypy/rpython/lltypesystem/rdict.py
==============================================================================
--- pypy/branch/rdict-index-based/pypy/rpython/lltypesystem/rdict.py	(original)
+++ pypy/branch/rdict-index-based/pypy/rpython/lltypesystem/rdict.py	Mon Sep 11 11:59:21 2006
@@ -478,6 +478,8 @@
     i = r_uint(hash & mask) 
     # do the first try before any looping 
     entry = entries[i]
+    found_freeslot = False
+    freeslot_index = r_uint(0)
     if entry.valid():
         checkingkey = entry.key
         if checkingkey == key:
@@ -493,9 +495,9 @@
                     return ll_dict_lookup(d, key, hash)
             if found:
                 return i   # found the entry
-        freeslot_index = -1
     elif entry.everused():
         freeslot_index = i
+        found_freeslot = True
     else:
         return i    # pristine entry -- lookup failed
 
@@ -506,7 +508,7 @@
         i = ((i << 2) + i + perturb + 1) & mask
         entry = entries[i]
         if not entry.everused():
-            if freeslot_index >= 0:
+            if found_freeslot:
                 return freeslot_index
             else:
                 return i
@@ -526,8 +528,9 @@
                         return ll_dict_lookup(d, key, hash)
                 if found:
                     return i
-        elif freeslot_index < 0:
-            freeslot_index = i 
+        elif not found_freeslot:
+            freeslot_index = i
+            found_freeslot = True
         perturb >>= PERTURB_SHIFT
 
 def ll_dict_lookup_clean(d, hash):



More information about the Pypy-commit mailing list