[23504] Optimize (de)serialization of flat, non-primitive arrays#489
Open
[23504] Optimize (de)serialization of flat, non-primitive arrays#489
Conversation
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
…ucts, unions and bitsets Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
This was referenced Jul 23, 2025
Comment on lines
+54
to
+55
| eProsima_user_DllExport bool is_$struct.cScopedname$_cdr_plain( | ||
| eprosima::fastdds::dds::DataRepresentationId_t data_representation) |
Member
There was a problem hiding this comment.
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.
MiguelCompany
requested changes
Jul 30, 2025
Comment on lines
+182
to
+187
| std::memcpy( | ||
| scdr.get_current_position(), | ||
| array_ptr, | ||
| (array_size - 1) * sizeof($struct.scopedname$)); | ||
|
|
||
| scdr.jump((array_size -1) * sizeof($struct.scopedname$)); |
Member
There was a problem hiding this comment.
Suggested change
| 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); | |
| } |
Comment on lines
+257
to
+262
| 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$)); |
Member
There was a problem hiding this comment.
Apply similar changes here
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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