-
Notifications
You must be signed in to change notification settings - Fork 37.4k
clang-tidy: Add more performance-*
checks and related fixes
#26642
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
Conversation
8000
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. 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. ConflictsReviewers, this pull request conflicts with the following ones:
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. |
Concept ACK |
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.
ACK 66b5bdd
src/.clang-tidy
Outdated
-performance-no-int-to-ptr, | ||
-performance-unnecessary-value-param, |
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.
Is there a reason why these two are not enabled?
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.
Is there a reason why they these two are not enabled?
The required fixes seem too invasive for this PR.
src/.clang-tidy
Outdated
@@ -7,6 +7,7 @@ modernize-use-default-member-init, | |||
modernize-use-nullptr, | |||
performance-faster-string-find, | |||
performance-for-range-copy, | |||
performance-inefficient-string-concatenation, |
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.
Not sure. This makes the code pretty verbose and it is unclear whether append or strprintf should be used. Also, while this check is disabled for non-loops. In our code it is only triggered on errors in loops.
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.
Thanks! Updated.
66b5bdd
to
0524c30
Compare
Updated 66b5bdd -> 0524c30 (pr26642.01 -> pr26642.02):
|
0524c30
to
ecb0262
Compare
…move` clang-tidy check 9567bfe clang-tidy: Add `performance-no-automatic-move` check (Hennadii Stepanov) Pull request description: Split from bitcoin/bitcoin#26642 as [requested](bitcoin/bitcoin#26642 (comment)). For the problem description see https://clang.llvm.org/extra/clang-tidy/checks/performance/no-automatic-move.html. The following types are affected: - `std::pair<CAddress, NodeSeconds>` - `std::vector<CAddress>` - `UniValue`, also see bitcoin/bitcoin#25429 - `QColor` - `CBlock` - `MempoolAcceptResult` - `std::shared_ptr<CWallet>` - `std::optional<SelectionResult>` - `CTransactionRef`, which is `std::shared_ptr<const CTransaction>` ACKs for top commit: andrewtoth: ACK 9567bfe aureleoules: ACK 9567bfe Tree-SHA512: 9b6a5d539205b41d2c86402d384318ed2e1d89e66333ebd200a48fd7df3ce6f6c60a3e989eda5cc503fb34b8d82526f95e56776e1af51e63b49e3a1fef72dbcb
…ang-tidy check 9567bfe clang-tidy: Add `performance-no-automatic-move` check (Hennadii Stepanov) Pull request description: Split from bitcoin#26642 as [requested](bitcoin#26642 (comment)). For the problem description see https://clang.llvm.org/extra/clang-tidy/checks/performance/no-automatic-move.html. The following types are affected: - `std::pair<CAddress, NodeSeconds>` - `std::vector<CAddress>` - `UniValue`, also see bitcoin#25429 - `QColor` - `CBlock` - `MempoolAcceptResult` - `std::shared_ptr<CWallet>` - `std::optional<SelectionResult>` - `CTransactionRef`, which is `std::shared_ptr<const CTransaction>` ACKs for top commit: andrewtoth: ACK 9567bfe aureleoules: ACK 9567bfe Tree-SHA512: 9b6a5d539205b41d2c86402d384318ed2e1d89e66333ebd200a48fd7df3ce6f6c60a3e989eda5cc503fb34b8d82526f95e56776e1af51e63b49e3a1fef72dbcb
ecb0262
to
1f1b3fd
Compare
Rebased ecb0262 -> 1f1b3fd (pr26642.03 -> pr26642.04) on top of the merged #26758. |
CI fails. Also, the first commit could be split up? |
1f1b3fd
to
38f8938
Compare
Done in #26905. |
Rebased 1f1b3fd -> 38f8938 (pr26642.04 -> pr26642.05) on top of the merged bitcoin-core/gui#686.
Should be green now :) |
…idy`'s check names 06fc293 refactor: Remove duplication of clang-tidy's check names (Hennadii Stepanov) Pull request description: This PR removes duplication of `clang-tidy`'s check names. No behavior change. Split up from bitcoin/bitcoin#26642 as [requested](bitcoin/bitcoin#26642 (comment)). ACKs for top commit: fanquake: ACK 06fc293 Tree-SHA512: a21bef3d7d7201e14565b526af2eae7a90cf0f792803704a80a70a4c78f07ef2a2eef6a8dced80361efbf13291ecccb0977378b9532fc30970a2070426e4d82c
38f8938
to
9e81656
Compare
Done in #27311. Making this PR a draft for now. |
8fe27fb ci: Use clang-15 in "tidy" task (Hennadii Stepanov) Pull request description: Newer tools usually are better in terms of features and bug fixes. Requested in bitcoin/bitcoin#26642 (comment). Split from bitcoin/bitcoin#26766. ACKs for top commit: MarcoFalke: lgtm ACK 8fe27fb Tree-SHA512: 62be3307d488fc4f75c40c0fa095aaa091aade2d5fe85296b56751e006c801f9d58c72c5cee8c0a0b1ba1a43804e315a3301c03e6e394bb3f3eb9b763fbb6271
Seeing lots of https://cirrus-ci.com/task/6739422046060544?logs=ci#L339: /tmp/cirrus-ci-build/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/rpc/server.cpp:88:9: error: 'push_back' is called inside a loop; consider pre-allocating the container capacity before the loop [performance-inefficient-vector-operation,-warnings-as-errors]
vCommands.push_back(make_pair(entry.second.front()->category + entry.first, entry.second.front()));
^
/tmp/cirrus-ci-build/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/rpc/server.cpp:516:39: error: 'emplace_back' is called inside a loop; consider pre-allocating the container capacity before the loop [performance-i617 warnings generated. |
Sorry. Pushed a wrong branch. Should be OK now. |
re-ACK 09383b6 Locally, I'm also getting a bunch of (though still on clang-14):
after running:
|
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.
code review ACK 09383b6
Updated 09383b6 -> 03ec5b6 (pr26642.12 -> pr26642.13, diff): |
ACK 03ec5b6 |
re-ACK 03ec5b6 |
…related fixes 03ec5b6 clang-tidy: Exclude `performance-*` checks rather including them (Hennadii Stepanov) 2400437 clang-tidy: Add `performance-type-promotion-in-math-fn` check (Hennadii Stepanov) 7e975e6 clang-tidy: Add `performance-inefficient-vector-operation` check (Hennadii Stepanov) 516b75f clang-tidy: Add `performance-faster-string-find` check (Hennadii Stepanov) Pull request description: ACKs for top commit: martinus: ACK 03ec5b6 TheCharlatan: re-ACK [03ec5b6](bitcoin@03ec5b6) Tree-SHA512: 2dfa52f9131da88826f32583bfd534a56a998477db9804b7333c0e7ac0b6b36141009755c7163b9f95d0ecbf5c2cb63f8a69ce4b114bb83423faed21b50cec67
No description provided.