Skip to content

Commit

Permalink
feat: speed up readers in the unmarshall path (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Sep 13, 2023
1 parent 288ffbe commit f9b61b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/dbus_fast/_private/unmarshaller.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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_)

Expand Down
6 changes: 3 additions & 3 deletions src/dbus_fast/_private/unmarshaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def _read_sock_with_fds(self, pos: _int, missing_bytes: _int) -> None:
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:
Expand All @@ -322,7 +322,7 @@ def _read_sock_without_fds(self, pos: _int) -> None:
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:
Expand All @@ -333,7 +333,7 @@ def _read_stream(self, pos: _int, missing_bytes: _int) -> bytes:
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:
Expand Down

0 comments on commit f9b61b8

Please sign in to comment.