feat: small speed ups to unmarshall message creation (#27)
This commit is contained in:
@@ -318,6 +318,9 @@ class Unmarshaller:
|
|||||||
signature=tree.signature,
|
signature=tree.signature,
|
||||||
body=[self.read_argument(t) for t in tree.types] if self.body_len else [],
|
body=[self.read_argument(t) for t in tree.types] if self.body_len else [],
|
||||||
serial=self.serial,
|
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):
|
def unmarshall(self):
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ class Message:
|
|||||||
signature: str = "",
|
signature: str = "",
|
||||||
body: List[Any] = [],
|
body: List[Any] = [],
|
||||||
serial: int = 0,
|
serial: int = 0,
|
||||||
|
validate: bool = True,
|
||||||
):
|
):
|
||||||
self.destination = destination
|
self.destination = destination
|
||||||
self.path = path
|
self.path = path
|
||||||
@@ -134,6 +135,8 @@ class Message:
|
|||||||
self.body = body
|
self.body = body
|
||||||
self.serial = serial
|
self.serial = serial
|
||||||
|
|
||||||
|
if not validate:
|
||||||
|
return
|
||||||
if self.destination is not None:
|
if self.destination is not None:
|
||||||
assert_bus_name_valid(self.destination)
|
assert_bus_name_valid(self.destination)
|
||||||
if self.interface is not None:
|
if self.interface is not None:
|
||||||
|
|||||||
@@ -765,10 +765,10 @@ class BaseMessageBus:
|
|||||||
|
|
||||||
if msg.message_type == MessageType.SIGNAL:
|
if msg.message_type == MessageType.SIGNAL:
|
||||||
if msg._matches(
|
if msg._matches(
|
||||||
|
member="NameOwnerChanged", # least likely to match
|
||||||
sender="org.freedesktop.DBus",
|
sender="org.freedesktop.DBus",
|
||||||
path="/org/freedesktop/DBus",
|
path="/org/freedesktop/DBus",
|
||||||
interface="org.freedesktop.DBus",
|
interface="org.freedesktop.DBus",
|
||||||
member="NameOwnerChanged",
|
|
||||||
):
|
):
|
||||||
[name, old_owner, new_owner] = msg.body
|
[name, old_owner, new_owner] = msg.body
|
||||||
if new_owner:
|
if new_owner:
|
||||||
|
|||||||
Reference in New Issue
Block a user