Skip to content

Commit

Permalink
feat: speed up unmarshall (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Oct 27, 2022
1 parent 85d2102 commit e1836b2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 1 addition & 3 deletions src/dbus_fast/_private/unmarshaller.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,8 @@ cdef class Unmarshaller:

cpdef read_string_unpack(self, object type_)

cdef _read_string_unpack(self)

@cython.locals(
buf_bytes=cython.bytearray,
str_start=cython.uint,
)
cdef _read_string_unpack(self)

Expand Down
14 changes: 8 additions & 6 deletions src/dbus_fast/_private/unmarshaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,17 @@ def read_variant(self, type_: SignatureType) -> Variant:
return self._read_variant()

def _read_variant(self) -> Variant:
tree = get_signature_tree(self._read_signature())
signature_type = tree.types[0]
signature = self._read_signature()
# verify in Variant is only useful on construction not unmarshalling
token = signature_type.token
if token == "n":
return Variant(tree, self._read_int16_unpack(), False)
if signature == "n":
return Variant(
get_signature_tree(signature), self._read_int16_unpack(), False
)
tree = get_signature_tree(signature)
signature_type = tree.types[0]
return Variant(
tree,
self._readers[token](self, signature_type),
self._readers[signature_type.token](self, signature_type),
False,
)

Expand Down

0 comments on commit e1836b2

Please sign in to comment.