Author: Maciej Fijalkowski <[email protected]>
Branch: rdict-experiments-2
Changeset: r59842:292fea80a9e1
Date: 2013-01-07 16:38 +0200
http://bitbucket.org/pypy/pypy/changeset/292fea80a9e1/

Log:    use INTs

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
@@ -346,8 +346,12 @@
 
 def _ll_malloc_indexes(n):
     # XXXX 64 bit only
-    res = lltype.cast_opaque_ptr(llmemory.GCREF,
-                 lltype.malloc(DICTINDEX_SIGNED.TO, n))
+    if n < MAX_INT:
+        res = lltype.cast_opaque_ptr(llmemory.GCREF,
+                                     lltype.malloc(DICTINDEX_INT.TO, n))
+    else:
+        res = lltype.cast_opaque_ptr(llmemory.GCREF,
+                                     lltype.malloc(DICTINDEX_SIGNED.TO, n))
     i = 0
     while i < n:
         ll_index_setitem(n, res, i, FREE)
@@ -355,10 +359,17 @@
     return res
 
 def ll_index_getitem(size, indexes, i):
+    if size < MAX_INT:
+        return rffi.cast(lltype.Signed,
+                         lltype.cast_opaque_ptr(DICTINDEX_INT, indexes)[i])
     return lltype.cast_opaque_ptr(DICTINDEX_SIGNED, indexes)[i]
 
 def ll_index_setitem(size, indexes, i, v):
-    lltype.cast_opaque_ptr(DICTINDEX_SIGNED, indexes)[i] = v
+    if size < MAX_INT:
+        lltype.cast_opaque_ptr(DICTINDEX_INT, indexes)[i] = rffi.cast(
+            rffi.INT_real, v)
+    else:
+        lltype.cast_opaque_ptr(DICTINDEX_SIGNED, indexes)[i] = v
 
 def ll_dict_copy_indexes(size, from_indexes, to_indexes):
     i = 0
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to