Skip to content

Commit

Permalink
feat: reduce overhead to reset between messages (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Sep 10, 2023
1 parent 42bbff5 commit da30b04
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/dbus_fast/_private/unmarshaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,23 +258,17 @@ def _next_message(self) -> None:
self._buf = bytearray()
else:
del self._buf[:to_clear]
self._message = None
self._pos = 0
self._body_len = 0
self._serial = 0
self._header_len = 0
self._message_type = 0
self._flag = 0
self._msg_len = 0
self._is_native = 0
self._read_complete = False
self._msg_len = 0 # used to check if we have ready the header
self._read_complete = False # used to check if we have ready the message
# No need to reset the unpack functions, they are set in _read_header
# every time a new message is processed.

@property
def message(self) -> Optional[Message]:
"""Return the message that has been unmarshalled."""
return self._message
if self._read_complete:
return self._message
return None

def _has_another_message_in_buffer(self) -> bool:
"""Check if there is another message in the buffer."""
Expand Down

0 comments on commit da30b04

Please sign in to comment.