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

Bump bytes to 0.5 #1367

Closed
wants to merge 1 commit into from

Conversation

bltavares
Copy link

bytes 0.5 had a couple of breaking changes, specially the split of
Bytes and BytesMut.

Given how much this code use methods avaialable only on BytesMut, this
comit changes the internal field to use this struct and some smaller
code changes to adapt to it.

Closes #1351

`bytes` 0.5 had a couple of breaking changes, specially the split of
`Bytes` and `BytesMut`.

Given how much this code use methods avaialable only on `BytesMut`, this
comit changes the internal field to use this struct and some smaller
code changes to adapt to it.

Closes libp2p#1351
@@ -29,17 +29,17 @@ pub use self::protocol::Protocol;

/// Representation of a Multiaddr.
#[derive(PartialEq, Eq, Clone, Hash)]
pub struct Multiaddr { bytes: Bytes }
pub struct Multiaddr { bytes: BytesMut }
Copy link
Contributor

Choose a reason for hiding this comment

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

Cloning Bytes is cheap, cloning BytesMut not so much. If we move away from Bytes we might as well use a Vec<u8> as we did in the past.

Copy link
Author

Choose a reason for hiding this comment

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

I don't know much about memory cost of either. Would you like me to change to Vec<u8> on this PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, I think we should leave the implementation as is for the time being and not upgrade to bytes-0.5. Eventually we will probably want a custom copy-on-write implementation with cheap clones for shared Multiaddr values.

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.

2 participants