Commits

Alex Gaynor committed 37ae371

collapse this into one loop, now seems faster than current dict at 25000000 iterations

  • Participants
  • Parent commits 7ad06da
  • Branches rdict-experiments

Comments (0)

Files changed (1)

File pypy/rlib/dict.py

         n = new_size
         self.indices = self._make_index(n)
         PERTURB_SHIFT = 5
+        new_values = lltype.malloc(TP, new_size * 2 / 3 + 1)
         for index in range(self.used):
             hashvalue = self.values[index].key
             if hashvalue < 0:
                 i = i & (n - 1)
                 perturb >>= PERTURB_SHIFT
             self.indices[i] = index
+            new_values[index].key = self.values[index].key
+            new_values[index].value = self.values[index].value
         self.filled = self.used
-        old_values = self.values
-        self.values = lltype.malloc(TP, new_size * 2 / 3 + 1)
-        for i in range(self.used):
-            self.values[i].key = old_values[i].key
-            self.values[i].value = old_values[i].value
+        self.values = new_values
 
     def clear(self):
         self.indices = self._make_index(8)