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

Prevent inefficient copying when using not_null::get #1059

Merged
merged 2 commits into from
Oct 11, 2022

Conversation

dmitrykobets-msft
Copy link
Member

Issue #550 highlighted overhead in not_null::get for larger types such as shared_ptr. Every call to get would return a copy of the contained value.
This PR implements Herb's suggestion for changing the return type of not_null::get. The not_null's value will now only be copied if it is "trivially copyable"; otherwise, it will be returned by const reference.
Note: this change also forces the returned copy to be const.

@dmitrykobets-msft dmitrykobets-msft changed the title Remove inefficient copying when using not_null::get Prevent inefficient copying when using not_null::get Oct 10, 2022
@hsutter
Copy link
Collaborator

hsutter commented Oct 11, 2022

LGTM, thanks Dmitry!

@dmitrykobets-msft dmitrykobets-msft merged commit 991fa66 into microsoft:main Oct 11, 2022
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

Successfully merging this pull request may close these issues.

None yet

2 participants