Skip to content

Commit

Permalink
feat: small speed up to processing bluez passive data
Browse files Browse the repository at this point in the history
This is a ~5% speed up
  • Loading branch information
bdraco committed Aug 9, 2023
1 parent fe53393 commit 0f1f22d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/dbus_fast/message_bus.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ cdef object MessageFlag
cdef object MESSAGE_TYPE_CALL
cdef object MESSAGE_TYPE_SIGNAL
cdef object NO_REPLY_EXPECTED_VALUE
cdef object SWALLOW_UNEXPECTED_REPLY
cdef object assert_object_path_valid
cdef object assert_bus_name_valid

cdef _expects_reply(Message msg)

cpdef _swallow_unexpected_reply(Message msg)

cdef class SendReply:

Expand Down
5 changes: 4 additions & 1 deletion src/dbus_fast/message_bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def _swallow_unexpected_reply(msg: _Message) -> None:
"""Swallow a reply if it's not expected."""


SWALLOW_UNEXPECTED_REPLY = _swallow_unexpected_reply


class SendReply:
"""A context manager to send a reply to a message."""

Expand Down Expand Up @@ -860,7 +863,7 @@ def _process_message(self, msg: _Message) -> None:
if not handled:
handler = self._find_message_handler(msg)
if not _expects_reply(msg):
handler(msg, _swallow_unexpected_reply)
handler(msg, SWALLOW_UNEXPECTED_REPLY)
return

send_reply = SendReply(self, msg)
Expand Down

0 comments on commit 0f1f22d

Please sign in to comment.