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

Improve Optional not to allocate on heap in case of containers #72

Open
Mi-La opened this issue Feb 17, 2025 · 0 comments
Open

Improve Optional not to allocate on heap in case of containers #72

Mi-La opened this issue Feb 17, 2025 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@Mi-La
Copy link
Collaborator

Mi-La commented Feb 17, 2025

Currently zserio::Optional<T> allocates on heap for objects bigger than a hard-coded threshold (3 * sizeof(void*)). However in some cases it can be worthless to allocate T on heap, especially when the T allocates on heap by itself - i.e. when T is a container. Consider std::vector and std::string (including pmr versions).

We already have similar optimization for zserio::View<T> - see #38.

Also consider to do similar improvement in zserio::Variant.

@Mi-La Mi-La added the enhancement New feature or request label Feb 17, 2025
@mikir mikir added this to the Backlog milestone Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants