forked from home-assistant/core
Use bytes join fast path for large states payload (#110694)
b"".join has a fast path for when there are more than two bytes-strings to combine https://github.com/python/cpython/blob/f383ca1a6fa1a2a83c8c1a0e56cf997c77fa2893/Objects/stringlib/join.h#L123
This commit is contained in:
@@ -222,7 +222,7 @@ class APIStatesView(HomeAssistantView):
|
||||
if entity_perm(state.entity_id, "read")
|
||||
)
|
||||
response = web.Response(
|
||||
body=b"[" + b",".join(states) + b"]",
|
||||
body=b"".join((b"[", b",".join(states), b"]")),
|
||||
content_type=CONTENT_TYPE_JSON,
|
||||
zlib_executor_size=32768,
|
||||
)
|
||||
|
||||
@@ -356,7 +356,9 @@ def _send_handle_get_states_response(
|
||||
) -> None:
|
||||
"""Send handle get states response."""
|
||||
connection.send_message(
|
||||
construct_result_message(msg_id, b"[" + b",".join(serialized_states) + b"]")
|
||||
construct_result_message(
|
||||
msg_id, b"".join((b"[", b",".join(serialized_states), b"]"))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user