From 8f7f982a75fe9c998e5a983090e361ba52e2e6a3 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 26 Oct 2022 14:07:22 -0500 Subject: [PATCH] feat: speed up unmarshaller (#113) --- src/dbus_fast/_private/unmarshaller.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/dbus_fast/_private/unmarshaller.py b/src/dbus_fast/_private/unmarshaller.py index 4ecb6c3..86abdad 100644 --- a/src/dbus_fast/_private/unmarshaller.py +++ b/src/dbus_fast/_private/unmarshaller.py @@ -365,8 +365,7 @@ class Unmarshaller: signature_len = buf[self._pos] # byte o = self._pos + 1 self._pos += signature_len + 2 # one for the byte, one for the '\0' - type_ = get_signature_tree(buf[o : o + signature_len].decode()).types[0] - token = type_.token + token = buf[o : o + signature_len].decode() # Now that we have the token we can read the variant value key = HEADER_MESSAGE_ARG_NAME[field_0] # Strings and signatures are the most common types @@ -378,7 +377,7 @@ class Unmarshaller: else: # There shouldn't be any other types in the header # but just in case, we'll read it using the slow path - headers[key] = readers[type_.token](self, type_) + headers[key] = readers[token](self, get_signature_tree(token).types[0]) return headers def _read_header(self) -> None: