I added const references to some variables to avoid unnecessarily copying objects.
Also added two clang-tidy checks : performance-for-range-copy and performance-unnecessary-copy-initialization.
I added const references to some variables to avoid unnecessarily copying objects.
Also added two clang-tidy checks : performance-for-range-copy and performance-unnecessary-copy-initialization.
Concept ACK
I agree with removing unused variables, as this makes the code cleaner and free of redundancies.
I verified that all the variables in the first and second commit either had their value reassigned before being used or were completely unused in their lifetime.
I verified that the variables in the third commit had their values unchanged, so it makes sense to make them a const variable.
I think merging the first and second commit would be a good idea as they are similar.
I would give the test file another view to confirm no other instance of unused variable has been left in the test file.
168@@ -169,7 +169,7 @@ const std::set<BlockFilterType>& AllBlockFilterTypes()
169
170 static std::once_flag flag;
171 std::call_once(flag, []() {
172- for (auto entry : g_filter_types) {
173+ for (const auto& entry : g_filter_types) {
371@@ -372,7 +372,6 @@ def test_sequence(self):
372 # since it greatly depends on inner-workings of blocks/mempool
373 # during "deep" re-orgs. Probably should "re-construct"
374 # blockchain/mempool state from notifications instead.
375- block_count = self.nodes[0].getblockcount()
We can decrease confidence. But this line worries me a little.
Any value below 100 introduces the risk of false positives, which would create an unacceptable maintenance burden.
Can we afford false positives for the chance of catching the few missed cases?
Can we afford false positives for the chance of catching the few missed cases?
It should either be tweaked to the point that it catches obviously dead code, or just removed. No point running a dead code linter that doesn’t catch dead code.
No point running a dead code linter that doesn’t catch dead code.
I agree with it.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, 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.
I’ve removed more unused variables and added more const references. Also enabled two clang-tidy checks to enforce const references where applicable.
In a9c05557d527f5266fa6dfd31ad7d22bcf06c3a8. Don’t mix refactoring Python test code & c++ networking code into the same commit. I’d actually suggest splitting the Python changes from this PR, given it’s unclear if Vulture is working. That should be followed up with, and without it, it’s not clear if your Python changes are exhaustive.
You should order your commits so that the changes follow logically. i.e perform refactors that allow turning on clang-tidy checks, before turning on the checks, not the other way around.
Please write commit messages that are meaningful, and explain your changes. Limit your commit titles to ~ 50 chars. (i.e 4407213ca10a3a28f253fb3e14e28940144f78ce).
This avoids initializing variables with the copy-constructor of a
non-trivially copyable type.
Thank you for the reviews.
I have addressed your comments @fanquake :
Though, I haven’t been able to tweak vulture to detect the unused variables I found manually.
5@@ -6,6 +6,8 @@ modernize-use-default-member-init,
6 modernize-use-nullptr,
7 readability-redundant-declaration,
8 readability-redundant-string-init,
9+performance-for-range-copy,
10+performance-unnecessary-copy-initialization,
Checks enabled: 'performance-for-range-copy' and 'performance-unnecessary-copy-initialization'
475@@ -476,7 +476,7 @@ bool Socks5(const std::string& strDest, uint16_t port, const ProxyCredentials* a
476 if (recvr != IntrRecvError::OK) {
477 return error("Error reading from proxy");
478 }
479- if ((recvr = InterruptibleRecv(pchRet3, 2, g_socks5_recv_timeout, sock)) != IntrRecvError::OK) {
480+ if (InterruptibleRecv(pchRet3, 2, g_socks5_recv_timeout, sock) != IntrRecvError::OK) {
481 return error("Error reading from proxy");
482 }
483 LogPrint(BCLog::NET, "SOCKS5 connected %s\n", strDest);
const
, but they look correct