Skip to content

Commit

Permalink
feat: small speed ups to unmarshall message creation (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Sep 24, 2022
1 parent 8e8a488 commit 0bce72a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/dbus_fast/_private/unmarshaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ def _read_body(self):
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):
Expand Down
3 changes: 3 additions & 0 deletions src/dbus_fast/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def __init__(
signature: str = "",
body: List[Any] = [],
serial: int = 0,
validate: bool = True,
):
self.destination = destination
self.path = path
Expand All @@ -134,6 +135,8 @@ def __init__(
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:
Expand Down
2 changes: 1 addition & 1 deletion src/dbus_fast/message_bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,10 +765,10 @@ def _process_message(self, msg):

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:
Expand Down

0 comments on commit 0bce72a

Please sign in to comment.