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

Add zero-copy make_mut #695

Merged
merged 10 commits into from
May 5, 2024
Merged

Add zero-copy make_mut #695

merged 10 commits into from
May 5, 2024

Conversation

Sytten
Copy link
Contributor

@Sytten Sytten commented Apr 14, 2024

Supersede #687
Closes #611

This is my first time contributing to bytes and this is quite a change, do let me know if you want more tests.

@Sytten Sytten mentioned this pull request Apr 14, 2024
src/bytes_mut.rs Outdated Show resolved Hide resolved
src/bytes_mut.rs Outdated Show resolved Hide resolved
src/bytes.rs Show resolved Hide resolved
@mattfbacon
Copy link

Why is x.make_mut() not the same as x.try_into_mut().unwrap_or_else(|| BytesMut::from(&*x))?

@Sytten
Copy link
Contributor Author

Sytten commented Apr 15, 2024

I mean I guess we could but we already have to handle the copy case in each to_mut vtable function so I dont really see the point in not using that. Plus it there is a small chance that a concurrent thread released the shared since we use acquire vs relaxed ordering.

src/bytes.rs Show resolved Hide resolved
@Sytten
Copy link
Contributor Author

Sytten commented Apr 23, 2024

Sorry I didnt have to work on it more, I will try this week. @braddunbar if you have for a review I would appreciate 🙏

@braddunbar
Copy link
Contributor

Oh, I missed the notification. Thanks for the ping! I'll take a look.

@Sytten
Copy link
Contributor Author

Sytten commented Apr 30, 2024

@braddunbar @Darksonn Gentle ping :)
I added the comment and an odd test. Let me know if we want to add more tests.

src/bytes_mut.rs Outdated Show resolved Hide resolved
src/bytes.rs Outdated Show resolved Hide resolved
src/bytes.rs Outdated Show resolved Hide resolved
src/bytes.rs Outdated Show resolved Hide resolved
src/bytes.rs Show resolved Hide resolved
tests/test_bytes.rs Outdated Show resolved Hide resolved
@Sytten
Copy link
Contributor Author

Sytten commented May 1, 2024

@Darksonn Done the improvements

src/bytes.rs Outdated Show resolved Hide resolved
src/bytes_mut.rs Outdated Show resolved Hide resolved
src/bytes_mut.rs Outdated Show resolved Hide resolved
@Sytten Sytten requested a review from Darksonn May 4, 2024 21:21
@Sytten
Copy link
Contributor Author

Sytten commented May 4, 2024

@braddunbar @Darksonn Ready for another round :)

Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

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

Mostly LGTM.

src/bytes_mut.rs Outdated Show resolved Hide resolved
src/bytes.rs Outdated Show resolved Hide resolved
@Sytten Sytten requested a review from Darksonn May 5, 2024 14:38
Copy link
Contributor

@braddunbar braddunbar left a comment

Choose a reason for hiding this comment

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

I spent some time combing over this today and I can't find anything to complain about. Thank you @Sytten!

@Darksonn Darksonn merged commit 86694b0 into tokio-rs:master May 5, 2024
15 checks passed
@Sytten Sytten deleted the feat-make-mut branch May 5, 2024 18:40
@braddunbar braddunbar mentioned this pull request May 6, 2024
@mox692 mox692 mentioned this pull request Jul 30, 2024
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.

Bytes::make_mut
5 participants