[pypy-commit] pypy faster-rstruct: change the inteface: now get_buffer_as_string_maybe also return the position inside the string: this will allow to support sub-buffers
antocuni
noreply at buildbot.pypy.org
Fri Nov 20 12:00:32 EST 2015
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: faster-rstruct
Changeset: r80807:c4eb83d8e88f
Date: 2015-11-20 16:52 +0100
http://bitbucket.org/pypy/pypy/changeset/c4eb83d8e88f/
Log: change the inteface: now get_buffer_as_string_maybe also return the
position inside the string: this will allow to support sub-buffers
diff --git a/rpython/rlib/rstruct/runpack.py b/rpython/rlib/rstruct/runpack.py
--- a/rpython/rlib/rstruct/runpack.py
+++ b/rpython/rlib/rstruct/runpack.py
@@ -39,11 +39,8 @@
def appendobj(self, value):
self.value = value
- def get_pos(self):
- return self.mr.inputpos
-
def get_buffer_as_string_maybe(self):
- return self.mr.input
+ return self.mr.input, self.mr.inputpos
def skip(self, size):
self.read(size) # XXX, could avoid taking the slice
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
@@ -138,8 +138,7 @@
@specialize.arg(0)
def unpack_fastpath(TYPE, fmtiter):
size = rffi.sizeof(TYPE)
- pos = fmtiter.get_pos()
- strbuf = fmtiter.get_buffer_as_string_maybe()
+ strbuf, pos = fmtiter.get_buffer_as_string_maybe()
if pos % size != 0 or strbuf is None or not ALLOW_FASTPATH:
raise CannotUnpack
fmtiter.skip(size)
More information about the pypy-commit
mailing list