-
Notifications
You must be signed in to change notification settings - Fork 38.7k
refactor: performance-for-range-copy in psbt.h #30253
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: performance-for-range-copy in psbt.h #30253
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee 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. |
|
Reference CI run: https://github.com/bitcoin/bitcoin/runs/25847037350 |
tdb3
left a comment
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.
Approach ACK.
Less copying makes sense. Briefly searched for other instances in psbt.h where potentially unnecessary copying is done.
Would it also make sense to adjust these references to const (or is there a specific reason why const should not be used here)? Adjusted to const auto& entry and ran unit and functional tests (no issues observed).
Lines 355 to 359 in fab01b5
| // Write unknown things | |
| for (auto& entry : unknown) { | |
| s << entry.first; | |
| s << entry.second; | |
| } |
Lines 780 to 784 in fab01b5
| // Write unknown things | |
| for (auto& entry : unknown) { | |
| s << entry.first; | |
| s << entry.second; | |
| } |
Lines 1013 to 1017 in fab01b5
| // Write the unknown things | |
| for (auto& entry : unknown) { | |
| s << entry.first; | |
| s << entry.second; | |
| } |
The examples you provided are already const references. In C++, when calling a member method that is marked |
theStack
left a comment
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 fab01b5
Thanks. |
Github-Pull: bitcoin#30253 Rebased-From: fab01b5
fab01b5 refactor: performance-for-range-copy in psbt.h (MarcoFalke) Pull request description: A copy of the partial signatures is not required before serializing them. For reference, this was found by switching the codebase to `std::span` (not sure why it wasn't found with `Span` though): ``` ./psbt.h:240:23: error: loop variable is copied but only used as const reference; consider making it a const reference [performance-for-range-copy,-warnings-as-errors] 240 | for (auto sig_pair : partial_sigs) { | ^ | const & ACKs for top commit: tdb3: ACK fab01b5 theStack: utACK fab01b5 Tree-SHA512: b55513d8191118499716684190ee568d171b50ae9171d246ca6e047f0cfd3ec14c9453d721e88af55e47bb41fa66cbafdbfb47bc5f9b8d82789e0a9b634b371b
c34e7ab Merge bitcoin#30534: guix: move bison from global scope, to Linux (merge-script) da11d29 Merge bitcoin#30282: Revert "contrib: macdeploy: monkey-patch gen-sdk to be deterministic" (merge-script) 20bcee8 Merge bitcoin#30281: Update leveldb subtree to latest upstream (merge-script) a74b1e2 Merge bitcoin#30253: refactor: performance-for-range-copy in psbt.h (merge-script) 2ea479f Merge bitcoin#29650: depends: drop 1 Qt determinism patch (fanquake) 6506f52 Merge bitcoin#28833: wallet: refactor: remove unused `SignatureData` instances in spkm's `FillPSBT` methods (Ava Chow) 6235590 Merge bitcoin#29213: doc, test: test and explain service flag handling (Ava Chow) 34bbe69 Merge bitcoin#28965: guix: remove input labels (fanquake) 490b390 Merge bitcoin#28859: guix: update signapple (drop macho & altgraph) (fanquake) a12ad80 Merge bitcoin#28325: test: wallet_backup.py, fix intermittent failure in "restore using dumped wallet" (fanquake) 15f8b74 Merge bitcoin#27779: guix: remove cURL from build env (fanquake) 1289d32 Merge bitcoin#27801: wallet: Add tracing for sqlite statements (fanquake) ba3aff7 Merge bitcoin-core/gui#729: test: Add missed header (Hennadii Stepanov) 536a265 Merge bitcoin#27209: ci: Remove unused EXPECTED_TESTS_DURATION_IN_SECONDS env var (glozow) f2caccd Merge bitcoin#27174: ci: bump lint task to bookworm for git v2.38 (fanquake) 0be2932 Merge bitcoin#27009: validation: Skip VerifyDB checks of level >=3 if dbcache is too small (fanquake) Pull request description: ## Issue being fixed or feature implemented Batch of trivial back ports ## What was done? ## How Has This Been Tested? Built locally; haven't reviewed commits yet. ## Breaking Changes ## Checklist: _Go over all the following points, and put an `x` in all the boxes that apply._ - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: UdjinM6: utACK c34e7ab kwvg: utACK c34e7ab Tree-SHA512: e20270e48273ad5fd5926e75b025fe69a70e698a82f0a11a1fa646c44a7affbd7a5f33eebcd7faa606e7adc2a888df141c660339d7240e6ed64f8525558215de
A copy of the partial signatures is not required before serializing them.
For reference, this was found by switching the codebase to
std::span(not sure why it wasn't found withSpanthough):