UniValue copies have been a source of performance related bugs and regressions, so it would be good to remove the copy constructors.
This is the first change toward the goal. This change uses a const UniValue& where possible.
See also:
UniValue copies have been a source of performance related bugs and regressions, so it would be good to remove the copy constructors.
This is the first change toward the goal. This change uses a const UniValue& where possible.
See also:
Review note: const will compile, but kill performance when std::move or RVO is intended.
Concept ACK
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--021abf342d371248e50ceaed478a90ca-->
See the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
<!--174a7506f384e20aa4161008e828411d-->
Reviewers, this pull request conflicts with the following ones:
read_json function into its own module by hebasto)outputs argument for bumpfee/psbtbumpfee by rodentrabies)If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
I am actually not sure how to fix all copies. Sometimes the std lib will copy if asked to:
std::vector<UniValue> a;
std::vector<UniValue> b;
a.insert(a.end(), b.begin(), b.end());
I guess you could add an explicit 'clone' method (like rust) and use that when it's really necessary to make a copy. It will probably make some things much more verbose though.
a.insert(a.end(), b.begin(), b.end());
In that case you can use
a.insert(a.end(), std::make_move_iterator(b.begin()), std::make_move_iterator(b.end()));
But I there might still be case where copy constructor is necessary, I remember that I had difficulties in my old PR as well
Concept ACK
ACK bbbbcfdb8e87f3151229ebc8c7b812a420d89b14 - as a first step.
While the changes are correct, I'll try to make them easier to review and more complete. For now, please review actual UniValue-copy bugfixes, like https://github.com/bitcoin/bitcoin/pull/25464
Concept ACK.
std::pair<A, B> is different from std::map<A, B>::value_type (aka
std::pair<const A, B>). So fix the type to also avoid a copy.
<!--cf906140f33d8803c4a75a2196329ecb-->
🐙 This pull request conflicts with the target branch and needs rebase.