-
Notifications
You must be signed in to change notification settings - Fork 790
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
Emplacing wherever possible and other misc enhancements #2498
Emplacing wherever possible and other misc enhancements #2498
Conversation
guilhermelawless
commented
Jan 20, 2020
- Using emplace/emplace_back where possible. Had to make explicit constructors for [tcp_]endpoint_attempt and channel wrappers
- Looping with range for-loops and using const refs
- Avoiding one hash and lookup in ::reachout
- Using insert/emplace to insert multiple elements in some places rather than a loop + single insert/emplace
- Using emplace/emplace_back where possible. Had to make explicit constructors for [tcp_]endpoint_attempt and channel wrappers - Looping with range for-loops and using const refs - Avoiding one hash and lookup in ::reachout - Using insert/emplace to insert multiple elements in some places, which is known to be faster for many elements
b8fa452
to
e25335f
Compare
I know we don't use exceptions much (yet), but I seem to recall there being issues with emplace on smart pointer containers and exception safety. |
@cryptocode The only location left is https://github.com/nanocurrency/nano-node/pull/2498/files#diff-a5e317b08279542bba01035dfeee7990R216 but what is constructed in-place is the pair |
@guilhermelawless I believe there is an exception safety case. Reading Scott Meyers item 42 now, but seems like it's related to custom deleters, which we've used only in one PR (which wasn't even merged). So probably not an issue, just something to be aware of going forward. |