Commits

Carl Friedrich Bolz  committed 42b1f54

don't compare via sort_key here either, but just use the identity of the descrs

  • Participants
  • Parent commits 0c00bfd

Comments (0)

Files changed (2)

File pypy/jit/metainterp/optimizeutil.py

-from pypy.rlib.objectmodel import r_dict
+from pypy.rlib.objectmodel import r_dict, compute_identity_hash
 from pypy.rlib.unroll import unrolling_iterable
 from pypy.jit.metainterp import resoperation
 
     mult = 1000003
     z = len(l)
     for descr in l:
-        y = descr.sort_key()
+        y = compute_identity_hash(descr)
         res = (res ^ y) * mult
         z -= 1
         mult += 82520 + z + z
     if len(l1) != len(l2):
         return False
     for i in range(len(l1)):
-        if l1[i].sort_key() != l2[i].sort_key():
+        if l1[i] is not l2[i]:
             return False
     return True
 

File pypy/jit/metainterp/test/test_optimizeopt.py

     assert not optimizeutil.descrlist_eq([LLtypeMixin.nextdescr, LLtypeMixin.valuedescr],
                                          [LLtypeMixin.valuedescr, LLtypeMixin.nextdescr])
 
+    # descrlist_eq should compare by identity of the descrs, not by the result
+    # of sort_key
+    class FakeDescr(object):
+        def sort_key(self):
+            return 1
+
+    assert not optimizeutil.descrlist_eq([FakeDescr()], [FakeDescr()])
+
 
 # ____________________________________________________________