database: remove unnecessary BytesIO conversion

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2023-02-05 07:56:04 -05:00
parent 559df5aea1
commit 4af483c786
No known key found for this signature in database
GPG Key ID: 5A1EB336DFB4C71B
1 changed files with 3 additions and 3 deletions

View File

@ -57,8 +57,8 @@ RECORD_DECODE_FUNCS = {
ord("d"): lambda x: struct.unpack("d", x[1:])[0],
ord("?"): lambda x: struct.unpack("?", x[1:])[0],
ord("s"): lambda x: bytes(x[1:]).decode(),
ord("["): lambda x: json.load(BytesIO(x)),
ord("{"): lambda x: json.load(BytesIO(x)),
ord("["): lambda x: json.loads(bytes(x)),
ord("{"): lambda x: json.loads(bytes(x)),
}
SENTINEL = SentinelClass.get_instance()
@ -712,7 +712,7 @@ class MoonrakerDatabase:
raise self.server.error(
f"Error encoding val: {value}, type: {type(value)}")
def _decode_value(self, bvalue: bytes) -> DBRecord:
def _decode_value(self, bvalue: Union[bytes, memoryview]) -> DBRecord:
fmt = bvalue[0]
try:
decode_func = RECORD_DECODE_FUNCS[fmt]