feat: speed up marshall write_string and write_variant (#138)

This commit is contained in:
J. Nick Koston 2022-11-03 10:09:43 +01:00 committed by GitHub
parent 3b2efffad2
commit 71cf52430b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -27,7 +27,7 @@ cdef class Marshaller:
signature_len=cython.uint,
written=cython.uint,
)
cpdef write_string(self, object value, object _type)
cpdef write_string(self, str value, object _type)
@cython.locals(
signature_len=cython.uint,
@ -59,6 +59,8 @@ cdef class Marshaller:
@cython.locals(
written=cython.uint,
signature=cython.str,
signature_bytes=cython.bytes,
)
cpdef write_variant(self, object variant, object type)

View File

@ -63,7 +63,9 @@ class Marshaller:
return written
def write_variant(self, variant: Variant, type_: SignatureType) -> int:
written = self._write_signature(variant.signature.encode())
signature = variant.signature
signature_bytes = signature.encode()
written = self._write_signature(signature_bytes)
written += self._write_single(variant.type, variant.value)
return written