-
Notifications
You must be signed in to change notification settings - Fork 66
[23504] Optimize (de)serialization of flat, non-primitive arrays #489
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Mario Dominguez <[email protected]>
…ucts, unions and bitsets Signed-off-by: Mario Dominguez <[email protected]>
| eProsima_user_DllExport bool is_$struct.cScopedname$_cdr_plain( | ||
| eprosima::fastdds::dds::DataRepresentationId_t data_representation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of this, we could have the following in Cdr.h:
template<typename _T>
extern bool is_cdr_plain(
const CdrVersion encoding);and then generate specializations here.
This way we could use the fully scoped C++ name.
| std::memcpy( | ||
| scdr.get_current_position(), | ||
| array_ptr, | ||
| (array_size - 1) * sizeof($struct.scopedname$)); | ||
|
|
||
| scdr.jump((array_size -1) * sizeof($struct.scopedname$)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| std::memcpy( | |
| scdr.get_current_position(), | |
| array_ptr, | |
| (array_size - 1) * sizeof($struct.scopedname$)); | |
| scdr.jump((array_size -1) * sizeof($struct.scopedname$)); | |
| std::size_t remaining = array_size - 1; | |
| if (0 < remaining) | |
| { | |
| std::size_t total_bytes = remaining * sizeof($struct.scopedname$); | |
| // Get current position and jump (would throw an exception if not enough buffer) | |
| auto dest = scdr.get_current_position(); | |
| scdr.jump(total_bytes); | |
| // It is now safe to do the copy | |
| std::memcpy(dest, array_ptr, total_bytes); | |
| } |
| std::memcpy( | ||
| reinterpret_cast<char*>(array_ptr), | ||
| scdr.get_current_position(), | ||
| (array_size - 1) * sizeof($struct.scopedname$)); | ||
|
|
||
| scdr.jump((array_size - 1) * sizeof($struct.scopedname$)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apply similar changes here
Description
This PR:
is_plain()implementation to theCdrAux.ipp. This makes necessary to define newc_scopedfree functions for each type with the implementation.(de)serialize_arraytemplate specializations in the generated typesmemcpy) if the types are both:max_cdr_serialized_sizeequalssizeof()These changes shall be introduced in a new minor.
Related PRs:
Contributor Checklist
Reviewer Checklist