[pypy-commit] pypy faster-rstruct-2: rpython fixes
antocuni
pypy.commits at gmail.com
Wed May 10 19:05:49 EDT 2017
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: faster-rstruct-2
Changeset: r91235:db941580b490
Date: 2017-05-11 00:58 +0200
http://bitbucket.org/pypy/pypy/changeset/db941580b490/
Log: rpython fixes
diff --git a/rpython/rlib/rstruct/ieee.py b/rpython/rlib/rstruct/ieee.py
--- a/rpython/rlib/rstruct/ieee.py
+++ b/rpython/rlib/rstruct/ieee.py
@@ -267,18 +267,19 @@
def pack_float(result, pos, x, size, be):
unsigned = float_pack(x, size)
- pack_float_to_buffer(result, pos, unsigned, size, be)
+ value = rarithmetic.longlongmask(unsigned)
+ pack_float_to_buffer(result, pos, value, size, be)
@jit.unroll_safe
-def pack_float_to_buffer(result, pos, unsigned, size, be):
+def pack_float_to_buffer(result, pos, value, size, be):
if be:
# write in reversed order
for i in range(size):
- c = chr((unsigned >> (i * 8)) & 0xFF)
+ c = chr((value >> (i * 8)) & 0xFF)
result.setitem(pos + size - i - 1, c)
else:
for i in range(size):
- c = chr((unsigned >> (i * 8)) & 0xFF)
+ c = chr((value >> (i * 8)) & 0xFF)
result.setitem(pos+i, c)
@jit.unroll_safe
diff --git a/rpython/rlib/rstruct/standardfmttable.py b/rpython/rlib/rstruct/standardfmttable.py
--- a/rpython/rlib/rstruct/standardfmttable.py
+++ b/rpython/rlib/rstruct/standardfmttable.py
@@ -49,6 +49,7 @@
for i in range(count - len(string)):
fmtiter.result.setitem(pos+i, '\x00')
else:
+ assert count >= 0
fmtiter.result.setslice(pos, string[:count])
fmtiter.advance(count)
More information about the pypy-commit
mailing list