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

Updating std::hast<EntityId_t> to get a better unordered containers distribution [6895] #868

Merged
merged 2 commits into from
Feb 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions include/fastrtps/rtps/common/EntityId_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,21 @@ struct hash<eprosima::fastrtps::rtps::EntityId_t>
std::size_t operator()(
const eprosima::fastrtps::rtps::EntityId_t& k) const
{
const uint32_t* aux = reinterpret_cast<const uint32_t*>(k.value);
return static_cast<std::size_t>(*aux);
// recover the participant entity counter
eprosima::fastrtps::rtps::octet value[4];

#if __BIG_ENDIAN__
value[3] = k.value[2];
value[2] = k.value[1];
value[1] = k.value[0];
value[0] = 0;
#else
value[3] = 0;
value[2] = k.value[0];
value[1] = k.value[1];
value[0] = k.value[2];
#endif
return static_cast<std::size_t>(*reinterpret_cast<const uint32_t*>(&value));
}
};

MiguelCompany marked this conversation as resolved.
Show resolved Hide resolved
Expand Down