feat: speed up readers in the unmarshall path (#253)

This commit is contained in:
J. Nick Koston 2023-09-13 13:21:25 -05:00 committed by GitHub
parent 288ffbe6bb
commit f9b61b8bc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -137,20 +137,20 @@ cdef class Unmarshaller:
recv=cython.tuple,
errno=cython.uint
)
cdef _read_sock_with_fds(self, unsigned int pos, unsigned int missing_bytes)
cdef void _read_sock_with_fds(self, unsigned int pos, unsigned int missing_bytes)
@cython.locals(
data=cython.bytes,
errno=cython.uint
)
cdef _read_sock_without_fds(self, unsigned int pos)
cdef void _read_sock_without_fds(self, unsigned int pos)
@cython.locals(
data=cython.bytes
)
cdef _read_stream(self, unsigned int pos, unsigned int missing_bytes)
cdef void _read_stream(self, unsigned int pos, unsigned int missing_bytes)
cdef _read_to_pos(self, unsigned int pos)
cdef void _read_to_pos(self, unsigned int pos)
cpdef read_boolean(self, SignatureType type_)

View File

@ -300,7 +300,7 @@ class Unmarshaller:
self._unix_fds.extend(
ARRAY("i", data[: len(data) - (len(data) % MAX_UNIX_FDS_SIZE)])
)
if msg == b"":
if not msg:
raise EOFError()
self._buf += msg
if len(self._buf) < pos:
@ -322,7 +322,7 @@ class Unmarshaller:
if errno == EAGAIN or errno == EWOULDBLOCK:
raise MARSHALL_STREAM_END_ERROR
raise
if data == b"":
if not data:
raise EOFError()
self._buf += data
if len(self._buf) >= pos:
@ -333,7 +333,7 @@ class Unmarshaller:
data = self._stream_reader(missing_bytes) # type: ignore[misc]
if data is None:
raise MARSHALL_STREAM_END_ERROR
if data == b"":
if not data:
raise EOFError()
self._buf += data
if len(self._buf) < pos: