Skip to content

Commit

Permalink
use ctypes.string_at for faster copying bytes (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
trunglebka authored Jan 8, 2025
1 parent ae1caaf commit 45f2ffd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions livekit-rtc/livekit/rtc/_ffi_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def ffi_event_callback(
data_ptr: ctypes.POINTER(ctypes.c_uint8), # type: ignore
data_len: ctypes.c_size_t,
) -> None:
event_data = bytes(data_ptr[: int(data_len)])
event_data = ctypes.string_at(data_ptr, int(data_len))
event = proto_ffi.FfiEvent()
event.ParseFromString(event_data)

Expand Down Expand Up @@ -235,7 +235,7 @@ def request(self, req: proto_ffi.FfiRequest) -> proto_ffi.FfiResponse:
)
assert handle != INVALID_HANDLE

resp_data = bytes(resp_ptr[: resp_len.value])
resp_data = ctypes.string_at(resp_ptr, resp_len.value)
resp = proto_ffi.FfiResponse()
resp.ParseFromString(resp_data)

Expand Down

0 comments on commit 45f2ffd

Please sign in to comment.