forked from dashpay/dash
-
Notifications
You must be signed in to change notification settings - Fork 717
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
[Refactor] Emplace elements in maps and vectors #1830
Merged
random-zebra
merged 4 commits into
PIVX-Project:master
from
random-zebra:202008_emplace
Sep 18, 2020
Merged
[Refactor] Emplace elements in maps and vectors #1830
random-zebra
merged 4 commits into
PIVX-Project:master
from
random-zebra:202008_emplace
Sep 18, 2020
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cef8945
to
6957ee8
Compare
Rebased. |
6957ee8
to
7a151a8
Compare
Rebased. |
7a151a8
to
2435a85
Compare
Rebased. |
2435a85
to
128589f
Compare
Rebased. |
Was going to ACK it but needs another rebase. |
emplace AddedNodeInfo and CRecipient in containers
128589f
to
e7eb446
Compare
Rebased again. |
furszy
approved these changes
Sep 17, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK e7eb446
Fuzzbawls
approved these changes
Sep 17, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
utACK e7eb446
furszy
added a commit
that referenced
this pull request
Oct 2, 2020
…cripts 9d40ace [BUG] Fix regression with emplace_back on cold-staking scripts (random-zebra) Pull request description: Bug introduced in #1830 (hunted down with @furszy ). Emplacing `uint160(key1)` into a vector of `CTxDestination` makes it construct the destination as a `CScriptID` instead of `CKeyID`. Therefore `ExtractDestinations` returns wrong addresses for cold staking scripts. ACKs for top commit: furszy: obvious ACK 9d40ace 🍺 . Fuzzbawls: ACK 9d40ace Tree-SHA512: 6d816500a3e5fcf1ed615c2adebe0f1cd04a61677e9b8d9a7b3055446bf295aef2a1cd898ab391c463298119f34a1bcd2bc72a5daeda37afd6b2115d1a3ab448
random-zebra
added a commit
that referenced
this pull request
Oct 2, 2020
…tion. b189cc3 Created coldstaking_tests unit test, checking cold staking script keys proper extraction. (furszy) Pull request description: Essentially proving #1830 bug and #1888 subsequent fix. ACKs for top commit: Fuzzbawls: ACK b189cc3 random-zebra: ACK b189cc3 (failing on master, passing on #1888). Merging... Tree-SHA512: 9af3975fe099a0e26feddf2fd52abee12864bf77bb511b2fbed6f39a9ea029cdc057d15157fafe842cd7e2b438447a08dc455c763feeecdc1378af637541eaf1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With C++11, variadic templates and perfect forwarding offer a new way of adding elements into a container by means of emplacing (creating in place).
This is particularly useful.
With the traditional
insert()
/push_back()
we are likely to make unnecessary copies (or move); for example, with maps, first thestd::pair<const K, V>
is created, and then it's copied to the container.With
emplace()
, instead, references to the key/value objects are forwarded directly to the constructor of thevalue_type
inside the data structure without making any copy ofstd::pair<const K,V>
.This PR replaces most instances of:
.insert(std::make_pair(K,V))
with.emplace(K, V)
.push_back(Class(Args...))
with.emplace_back(Args...)
in the whole code base.
It touches many files (therefore is surely conflicting with many open pull requests), but changes are trivial.