Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server::send_text_owned #36

Merged
merged 4 commits into from
Jun 11, 2021
Merged

Server::send_text_owned #36

merged 4 commits into from
Jun 11, 2021

Conversation

maciejhirsz
Copy link
Contributor

@maciejhirsz maciejhirsz commented Jun 10, 2021

This is somewhat analogous to send_binary_mut in that it allows us to do masking in place, which is one less copy for jsonrpsee.

Doing send_text_mut would be a closer mirror, but casting &mut str into &mut [u8] is unsafe (the original str slice might end up not being valid utf8). Soketto already supports owned buffers internally though, and since jsonrpsee spits out owned Strings, we can use that to make responses that one memcpy faster.

src/connection.rs Outdated Show resolved Hide resolved
src/connection.rs Outdated Show resolved Hide resolved
@maciejhirsz maciejhirsz merged commit 88007ee into develop Jun 11, 2021
@maciejhirsz maciejhirsz deleted the mh-send_text_owned branch June 11, 2021 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants