From 0f1f22d94319a3320a3ce9f21780891495769327 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 8 Aug 2023 23:02:12 -1000 Subject: [PATCH] feat: small speed up to processing bluez passive data This is a ~5% speed up --- src/dbus_fast/message_bus.pxd | 2 +- src/dbus_fast/message_bus.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/dbus_fast/message_bus.pxd b/src/dbus_fast/message_bus.pxd index fbec4700..9439345f 100644 --- a/src/dbus_fast/message_bus.pxd +++ b/src/dbus_fast/message_bus.pxd @@ -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: diff --git a/src/dbus_fast/message_bus.py b/src/dbus_fast/message_bus.py index 5d26b904..c32a9ea3 100644 --- a/src/dbus_fast/message_bus.py +++ b/src/dbus_fast/message_bus.py @@ -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.""" @@ -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)