[pypy-commit] pypy faster-rstruct-2: fix pack_int for the new interface

antocuni pypy.commits at gmail.com
Wed May 10 19:05:30 EDT 2017


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: faster-rstruct-2
Changeset: r91228:addb00e213ad
Date: 2017-05-10 11:55 +0200
http://bitbucket.org/pypy/pypy/changeset/addb00e213ad/

Log:	fix pack_int for the new interface

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
@@ -119,14 +119,18 @@
         value = method()
         if not min <= value <= max:
             raise StructError(errormsg)
+        #
+        pos = fmtiter.pos + size - 1        
         if fmtiter.bigendian:
             for i in unroll_revrange_size:
                 x = (value >> (8*i)) & 0xff
-                fmtiter.result.append(chr(x))
+                fmtiter.result.setitem(pos-i, chr(x))
         else:
+
             for i in unroll_revrange_size:
-                fmtiter.result.append(chr(value & 0xff))
+                fmtiter.result.setitem(pos-i, chr(value & 0xff))
                 value >>= 8
+        fmtiter.advance(size)
 
     _memo[key] = pack_int
     return pack_int


More information about the pypy-commit mailing list