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

Optimization of the alignment calculation using the Cdr::alignment() method does not work #211

Open
i-and opened this issue Jun 10, 2024 · 0 comments

Comments

@i-and
Copy link

i-and commented Jun 10, 2024

In version 2.2.1, all serialization and deserialization methods perform the following sequence of actions:

{
  size_t align = alignment(sizeof(SomeType));
  last_data_size_ = sizeof(SomeType);
  make_alignment(align);
  ...
}

Since last_data_size_ is zeroed in the make_alignment() method, subsequent alignment() calls will be performed with the full calculation of the expression:

inline size_t alignment(size_t data_size) const
{
    return data_size > last_data_size_ ? (data_size - ((offset_ - origin_) % data_size)) & (data_size - 1) : 0;
}

Apparently, optimization based on the use of last_data_size_ does not work in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant