Author: Maciej Fijalkowski <[email protected]>
Branch: rdict-experiments-2
Changeset: r59837:a02e95d6b5d1
Date: 2013-01-07 04:02 +0200
http://bitbucket.org/pypy/pypy/changeset/a02e95d6b5d1/
Log: use different sizes of 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
@@ -345,9 +345,15 @@
DICTINDEX_SIGNED = lltype.Ptr(lltype.GcArray(lltype.Signed))
DICTINDEX_INT = lltype.Ptr(lltype.GcArray(rffi.INT_real))
+MAX_INT = 2 ** 31 - 1
+
def _ll_malloc_indexes(n):
- res = lltype.malloc(DICTINDEX_SIGNED.TO, n)
- res = lltype.cast_opaque_ptr(DICTINDEXOPAQUE, res)
+ if n < MAX_INT:
+ res = lltype.malloc(DICTINDEX_INT.TO, n)
+ res = lltype.cast_opaque_ptr(DICTINDEXOPAQUE, res)
+ else:
+ res = lltype.malloc(DICTINDEX_SIGNED.TO, n)
+ res = lltype.cast_opaque_ptr(DICTINDEXOPAQUE, res)
i = 0
while i < n:
ll_index_setitem(n, res, i, FREE)
@@ -355,9 +361,16 @@
return res
def ll_index_getitem(size, indexes, i):
+ if size < MAX_INT:
+ res = lltype.cast_opaque_ptr(DICTINDEX_INT, indexes)[i]
+ return rffi.cast(lltype.Signed, res)
return lltype.cast_opaque_ptr(DICTINDEX_SIGNED, indexes)[i]
def ll_index_setitem(size, indexes, i, v):
+ if size < MAX_INT:
+ arg = rffi.cast(rffi.INT_real, v)
+ lltype.cast_opaque_ptr(DICTINDEX_INT, indexes)[i] = arg
+ return
lltype.cast_opaque_ptr(DICTINDEX_SIGNED, indexes)[i] = v
def ll_dict_copy_indexes(size, from_indexes, to_indexes):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit