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

Remove unnecessary allocations and unsafe #160

Merged
merged 2 commits into from
Jul 15, 2022

Conversation

andrewwhitehead
Copy link
Contributor

No description provided.

@@ -46,27 +53,29 @@ impl ZmqCommand {
}
}

impl TryFrom<BytesMut> for ZmqCommand {
impl TryFrom<Bytes> for ZmqCommand {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to Bytes for consistency

let command_len = buf.get_u8() as usize;
// command-name-char = ALPHA according to https://rfc.zeromq.org/spec:23/ZMTP/
let command_name =
unsafe { String::from_utf8_unchecked(buf.split_to(command_len).to_vec()) };
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is UB given that the peer may not be following the spec.

@Alexei-Kornienko
Copy link
Collaborator

Mostly LGTM. Could you please fix clippy error that pops in CI?

Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
@Alexei-Kornienko Alexei-Kornienko merged commit c7cbd1c into zeromq:master Jul 15, 2022
@andrewwhitehead andrewwhitehead deleted the fix/remove-allocs branch July 15, 2022 04:24
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.

None yet

3 participants