feat: small speed ups to unmarshall message creation (#27)

This commit is contained in:
J. Nick Koston 2022-09-23 19:35:39 -10:00 committed by GitHub
parent 8e8a48832e
commit 0bce72a76a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View File

@ -318,6 +318,9 @@ class Unmarshaller:
signature=tree.signature,
body=[self.read_argument(t) for t in tree.types] if self.body_len else [],
serial=self.serial,
# The D-Bus implementation already validates the message,
# so we don't need to do it again.
validate=False,
)
def unmarshall(self):

View File

@ -108,6 +108,7 @@ class Message:
signature: str = "",
body: List[Any] = [],
serial: int = 0,
validate: bool = True,
):
self.destination = destination
self.path = path
@ -134,6 +135,8 @@ class Message:
self.body = body
self.serial = serial
if not validate:
return
if self.destination is not None:
assert_bus_name_valid(self.destination)
if self.interface is not None:

View File

@ -765,10 +765,10 @@ class BaseMessageBus:
if msg.message_type == MessageType.SIGNAL:
if msg._matches(
member="NameOwnerChanged", # least likely to match
sender="org.freedesktop.DBus",
path="/org/freedesktop/DBus",
interface="org.freedesktop.DBus",
member="NameOwnerChanged",
):
[name, old_owner, new_owner] = msg.body
if new_owner: