Skip to content

Commit

Permalink
Restore lost comment
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzzypixelz committed Dec 20, 2024
1 parent 662530c commit 759c717
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rmw_zenoh_cpp/src/detail/zenoh_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ std::chrono::nanoseconds::rep ZenohReply::get_received_timestamp() const
///=============================================================================
Payload::Payload(const zenoh::Bytes & bytes)
{
// NOTE(fuzzypixelz): `zenoh::Bytes` is an list of reference-couted buffers. When the list of
// buffers contains exactly one element, it is not necessary to concatenate the list of buffers.
// In this case, we store a clone of the bytes object to maintain a non-zero reference-count on
// the buffer. This ensures that the slice into said buffer stays valid until we drop our copy
// of the bytes object (at the very least). This case corresponds to the `Contiguous`
// alternative of the `bytes_` variant and aims to optimize away a memcpy during "session-local"
// communication.

zenoh::Bytes::SliceIterator slices = bytes.slice_iter();
std::optional<zenoh::Slice> slice = slices.next();
if (!slice.has_value()) {
Expand Down

0 comments on commit 759c717

Please sign in to comment.