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

signal_template.hpp uses 'new' to create shared_ptr when it should use make_shared #58

Closed
BrianWeed opened this issue Feb 15, 2022 · 3 comments

Comments

@BrianWeed
Copy link

boost_1_78_0\boost\signals2\detail\signal_template.hpp lines 156, 309, 478, 500, and 513 use 'new' when make_shared would be more efficient. ( There's probably even more places in the code base that could use make_shared, but lines 156, and 513 were the ones flagged by the profiler, and are unnecessary bottlenecks).

Calling new to create a shared pointer forces an additional allocation for the shared count (new sp_counted_impl_p).
Using make_shared, on the other hand, combines the allocations into one, thereby cutting the total number of allocations/deallocations in half.

@mclow mclow transferred this issue from boostorg/boost Feb 15, 2022
@fmhess
Copy link
Collaborator

fmhess commented Feb 15, 2022

Using make_shared sounds fine, would you make a pull request to the develop branch with the changes? If not, let me know and I'll make the changes later.

@BrianWeed
Copy link
Author

BrianWeed commented Feb 15, 2022 via email

@fmhess
Copy link
Collaborator

fmhess commented May 25, 2022

These changes have been merged to master, so should be in boost 1.80

@fmhess fmhess closed this as completed May 25, 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

No branches or pull requests

2 participants