Skip to content

Commit

Permalink
Remove gid_hash_ from AttachmentData
Browse files Browse the repository at this point in the history
This member is computed in the constructor which is in turn called
in `rmw_publish`. This hash is not serialized as part of the attachment.
  • Loading branch information
fuzzypixelz committed Jan 13, 2025
1 parent 3739a0f commit 950a43a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
11 changes: 1 addition & 10 deletions rmw_zenoh_cpp/src/detail/attachment_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@ AttachmentData::AttachmentData(
const std::array<uint8_t, RMW_GID_STORAGE_SIZE> source_gid)
: sequence_number_(sequence_number),
source_timestamp_(source_timestamp),
source_gid_(source_gid),
gid_hash_(hash_gid(source_gid))
source_gid_(source_gid)
{
}

AttachmentData::AttachmentData(AttachmentData && data)
{
gid_hash_ = std::move(data.gid_hash_);
sequence_number_ = std::move(data.sequence_number_);
source_timestamp_ = std::move(data.source_timestamp_);
source_gid_ = data.source_gid_;
Expand All @@ -66,12 +64,6 @@ std::array<uint8_t, RMW_GID_STORAGE_SIZE> AttachmentData::copy_gid() const
return source_gid_;
}

///=============================================================================
size_t AttachmentData::gid_hash() const
{
return gid_hash_;
}

zenoh::Bytes AttachmentData::serialize_to_zbytes()
{
auto serializer = zenoh::ext::Serializer();
Expand Down Expand Up @@ -104,6 +96,5 @@ AttachmentData::AttachmentData(const zenoh::Bytes & bytes)
throw std::runtime_error("source_gid is not found in the attachment.");
}
this->source_gid_ = deserializer.deserialize<std::array<uint8_t, RMW_GID_STORAGE_SIZE>>();
gid_hash_ = hash_gid(this->source_gid_);
}
} // namespace rmw_zenoh_cpp
2 changes: 0 additions & 2 deletions rmw_zenoh_cpp/src/detail/attachment_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,13 @@ class AttachmentData final
int64_t sequence_number() const;
int64_t source_timestamp() const;
std::array<uint8_t, RMW_GID_STORAGE_SIZE> copy_gid() const;
size_t gid_hash() const;

zenoh::Bytes serialize_to_zbytes();

private:
int64_t sequence_number_;
int64_t source_timestamp_;
std::array<uint8_t, RMW_GID_STORAGE_SIZE> source_gid_;
size_t gid_hash_;
};
} // namespace rmw_zenoh_cpp

Expand Down

0 comments on commit 950a43a

Please sign in to comment.