Skip to content

Conversation

@camshaft
Copy link
Contributor

@camshaft camshaft commented Apr 4, 2025

Description of changes:

This change optimizes a read to a Bytes/BytesMut when the watermark consumes the entire chunk. In this case, it doesn't matter if the caller optimizes on bytes or not - it's better to replace self with an empty instance and return the chunk to potentially avoid copies.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@camshaft camshaft requested a review from Copilot April 4, 2025 06:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

quic/s2n-quic-core/src/buffer/reader/storage/bytes.rs:50

  • [nitpick] The variable name 'consumes_self' may be unclear; consider renaming it to 'is_full_read' to clearly indicate that it checks whether the entire buffer is being read.
let consumes_self = watermark == self.len();

quic/s2n-quic-core/src/buffer/reader/storage/bytes.rs:102

  • [nitpick] The variable name 'consumes_self' may be unclear in this context as well; consider renaming it to 'is_full_read' for consistency and improved readability.
let consumes_self = watermark == self.len();

@camshaft camshaft merged commit 89c62d6 into main Apr 4, 2025
123 of 126 checks passed
@camshaft camshaft deleted the camshaft/bytes-storage-opt branch April 4, 2025 13:25
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