- removed unnecessary value arguments.
- removed unnecessary copy initialization.
- removed unnecessary for range copy.
Avoid unnecessary copy of objects. #12158
pull ghost wants to merge 2 commits into bitcoin:master from changing 49 files +119 −107-
ghost commented at 7:32 pm on January 11, 2018: none
-
Avoid unnecessary copy of objects.
* removed unnecessary value arguments. * removed unnecessary copy initialization. * removed unnecessary for range copy.
-
ghost commented at 7:32 pm on January 11, 2018: none
I ran the tests with
make check
as well as the functional tests viatest/functional/test_runner.py
Everything seems fine to me.
Let me know if this is acceptable or whether there’s something I missed.
Regards,
-
in src/rpc/mining.cpp:106 in b460242a36 outdated
102@@ -103,7 +103,7 @@ UniValue getnetworkhashps(const JSONRPCRequest& request) 103 return GetNetworkHashPS(!request.params[0].isNull() ? request.params[0].get_int() : 120, !request.params[1].isNull() ? request.params[1].get_int() : -1); 104 } 105 106-UniValue generateBlocks(std::shared_ptr<CReserveScript> coinbaseScript, int nGenerate, uint64_t nMaxTries, bool keepScript) 107+UniValue generateBlocks(const std::shared_ptr<CReserveScript>& coinbaseScript, int nGenerate, uint64_t nMaxTries, bool keepScript)
ryanofsky commented at 7:48 pm on January 11, 2018:Probably more natural to just passconst CReserveScript*
than a const shared_ptr.
unknown commented at 7:54 pm on January 11, 2018:will do thatryanofsky commented at 7:50 pm on January 11, 2018: memberSeems like a good change but probably won’t be able to be merged soon given upcoming release & feature freeze.ghost commented at 7:55 pm on January 11, 2018: noneNo problem, I can just rebase it when the next merge window happens.Remove shared_ptr from mining interface. 7a385e8e72fanquake added the label Refactoring on Jan 13, 2018promag commented at 2:52 pm on February 3, 2018: memberNACK as is. Too much scattered and different type of changes.practicalswift commented at 4:34 pm on February 8, 2018: contributor@kekimusmaximus Did you use a static analyzer to identify these? Are the fixes exhaustive (covering all instances in the code base)?ghost commented at 4:58 pm on February 8, 2018: none@practicalswift Yes, I’m using an unusual setup, since I created a compile command database.
But at the crux of it it’s http://clang.llvm.org/extra/clang-tidy/index.html
On a more general note, what could be done is have a configure option that has a compilation dry run, where the compiler is set to clang-tidy.
It would also be useful to have maybe a list of agreed upon checks and committed to the repo. Ideally you’d have the CI run that also.
I could probably create a pull request for that, but at the end of the day the issues still need to be fixed.
ghost commented at 5:01 pm on February 8, 2018: noneYes fixes are exhaustivepracticalswift commented at 9:15 pm on February 8, 2018: contributor@kekimusmaximus Very nice! Did you create the compile command database using Bear (Build EAR)?
One way to increase the chance of getting this kind of changes accepted is to allow for other to recreate the process you used to identify the issues. That will allow others to verify that the changes are correct and exhaustive. Ideally that would include the commands used (including building the compile database) and the relevant output printed (say posted to a gist linked from here).
ghost commented at 10:00 pm on February 8, 2018: none@practicalswift Yes I used Bear with verbose make output.
Bear doesn’t work with bitcoin by default since the buildsystem makes use of libtool. Given I’m a CMake guy, I couldn’t figure out how to get around that so what I did was I hacked Bear.
Basically I added the following line to /usr//bin/bear.
250 re.compile(r’^libtool: compile : clang(++)?(-\d+(.\d+){0,2})?$’),
And of course ran ./configure with CC=“clang” And bear make V=1
Hope that helps. Ideally this would be integrated in the buildsystem, CMake already provides support for compilation databases.
I also tried to just pass CC=clang-tidy at configure time but that fails since IIRC in univalue the configure step tries to compile something to see if there’s support and that messes everything up. Again CMake guy.
ghost commented at 10:05 pm on February 8, 2018: noneWhat I also need to point out if you’re going to try this, since there’s classes of checks that can be automatically fixed if you pass fix.
It’s not that straight forward, so you need to evaluate the fixes by hand. Sometimes the suggested fixes are wrong for different reasons, I would say 90% of the time is ok except when it’s not :)
laanwj commented at 9:15 pm on March 29, 2018: memberAll in all, the changes in this PR make sense. Avoiding copies is good. But due to the large number of changes it’s very hard to review (as @promag says). It would make sense to split commits, or maybe even separate PRs, per category of changes - e.g. those that addstd::move
, those that addconst &
, the miscellaneous code style changes etc.laanwj commented at 12:33 pm on April 26, 2018: memberGoing to close this as it seems to be inactive, let me know if you want to pick it up again then I’ll reopen.laanwj closed this on Apr 26, 2018
MarcoFalke added the label Up for grabs on Apr 26, 2018MarcoFalke removed the label Up for grabs on Mar 5, 2019DrahtBot locked this on Dec 16, 2021
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-17 09:12 UTC
More mirrored repositories can be found on mirror.b10c.me