feat: improve performance of unmarshalling boolean Variants (#431)
* feat: improve performance of boolean Variants There are only two of these type and relatively common so we can use pre-constructed objects * chore: tweaks
This commit is contained in:
parent
1988984398
commit
888a3c3ea5
@ -109,6 +109,9 @@ cdef unsigned int TOKEN_LEFT_PAREN_AS_INT
|
||||
cdef object MARSHALL_STREAM_END_ERROR
|
||||
cdef object DEFAULT_BUFFER_SIZE
|
||||
|
||||
cdef Variant VARIANT_BOOL_TRUE
|
||||
cdef Variant VARIANT_BOOL_FALSE
|
||||
|
||||
cdef list _EMPTY_HEADERS
|
||||
|
||||
cdef cython.uint EAGAIN
|
||||
@ -178,7 +181,7 @@ cdef class Unmarshaller:
|
||||
|
||||
cpdef read_boolean(self, SignatureType type_)
|
||||
|
||||
cdef _read_boolean(self)
|
||||
cdef bint _read_boolean(self)
|
||||
|
||||
cpdef read_uint32_unpack(self, SignatureType type_)
|
||||
|
||||
|
||||
@ -120,6 +120,10 @@ TOKEN_LEFT_CURLY_AS_INT = ord("{")
|
||||
TOKEN_LEFT_PAREN_AS_INT = ord("(")
|
||||
|
||||
|
||||
VARIANT_BOOL_TRUE = Variant._factory(SIGNATURE_TREE_B, True)
|
||||
VARIANT_BOOL_FALSE = Variant._factory(SIGNATURE_TREE_B, False)
|
||||
|
||||
|
||||
ARRAY = array.array
|
||||
SOL_SOCKET = socket.SOL_SOCKET
|
||||
SCM_RIGHTS = socket.SCM_RIGHTS
|
||||
@ -539,7 +543,7 @@ class Unmarshaller:
|
||||
if token_as_int == TOKEN_S_AS_INT:
|
||||
return Variant._factory(SIGNATURE_TREE_S, self._read_string_unpack())
|
||||
if token_as_int == TOKEN_B_AS_INT:
|
||||
return Variant._factory(SIGNATURE_TREE_B, self._read_boolean())
|
||||
return VARIANT_BOOL_TRUE if self._read_boolean() else VARIANT_BOOL_FALSE
|
||||
if token_as_int == TOKEN_O_AS_INT:
|
||||
return Variant._factory(SIGNATURE_TREE_O, self._read_string_unpack())
|
||||
if token_as_int == TOKEN_U_AS_INT:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user