use const references where appropriate #6206

pull Diapolo wants to merge 1 commits into bitcoin:master from Diapolo:network changing 21 files +61 −63
  1. Diapolo commented at 1:39 pm on May 31, 2015: none
  2. laanwj commented at 8:05 am on June 1, 2015: member

    There are still a lot of these cases where a const reference can be used for strings throughout the source code. Instead of many little pulls I’d prefer (for post-0.11) a pull where they’re all addressed at once.

    A quick git grep string -- \*.h|grep -v '&' shows at least:

    • FormatParagraph
    • CAlert::AppliesTo
    • ParseScript()
    • GetWarnings()
    • ParseNetwork()
    • CRPCTable::operator[](std::string name)
    • CRPCTable::help(std::string name)
    • HelpExampleCli
    • HelpExampleRpc
    • runCommand()
    • CWallet::GetAccountAddresses
    • CWallet::CWallet(std::string strWalletFileIn)
    • CValidationState::Error
    • CNode(SOCKET hSocketIn, CAddress addrIn, std::string addrNameIn = "", bool fInboundIn=false)
  3. laanwj added the label Improvement on Jun 1, 2015
  4. Diapolo commented at 8:50 am on June 1, 2015: none
    I’m going to update this :).
  5. Diapolo commented at 9:09 am on June 1, 2015: none
    ParseNetwork() isn’t suitable, because we use boost::to_lower(net); inside.
  6. Diapolo renamed this:
    [net] make AddOneShot take a const reference
    use const references where appropriate
    on Jun 1, 2015
  7. Diapolo commented at 9:32 am on June 1, 2015: none
    @laanwj I catched all your results and also changed a few other occurances in BOOST_FOREACH loops and in the CNode constructor (unrelated to std::string). Mind reviewing it?
  8. in src/net.cpp: in 551deda9ed outdated
    1905@@ -1906,7 +1906,7 @@ bool CAddrDB::Read(CAddrMan& addr)
    1906 unsigned int ReceiveFloodSize() { return 1000*GetArg("-maxreceivebuffer", 5*1000); }
    1907 unsigned int SendBufferSize() { return 1000*GetArg("-maxsendbuffer", 1*1000); }
    1908 
    1909-CNode::CNode(SOCKET hSocketIn, CAddress addrIn, std::string addrNameIn, bool fInboundIn) :
    1910+CNode::CNode(const SOCKET& hSocketIn, const CAddress& addrIn, const std::string& addrNameIn, bool fInboundIn) :
    


    laanwj commented at 9:41 am on June 1, 2015:
    No need to do this for SOCKET, which is just an integer handle.

    Diapolo commented at 9:50 am on June 1, 2015:
    You are right, reverted for hSocketIn :), thanks.
  9. Diapolo commented at 11:24 am on June 1, 2015: none
    @laanwj I’m going to attach a second squashme pull, which covers BOOST_FOREACH and updated to constant refs if appropriate, if you want me to do so?
  10. laanwj commented at 11:25 am on June 1, 2015: member
    utACK
  11. laanwj commented at 11:28 am on June 1, 2015: member

    I’m going to attach a second squashme pull, which covers BOOST_FOREACH and updated to constant refs if appropriate, if you want me to do so?

    Yes, why not

  12. Diapolo commented at 12:06 pm on June 1, 2015: none
    @laanwj See 2nd commit.
  13. laanwj commented at 8:20 am on June 2, 2015: member
    utACK^2 . WIll merge this after #6121
  14. Diapolo commented at 8:31 am on June 2, 2015: none
    That’s fine, could be I forgot a few cases in the GUI code, but that can be a seperate pull.
  15. fanquake commented at 2:48 pm on June 3, 2015: member
    utACK
  16. laanwj commented at 4:48 pm on June 4, 2015: member
    Will merge after rebase. @diapolo can you please include getValStr() https://github.com/bitcoin/bitcoin/blob/master/src/univalue/univalue.h#L64 to return a const reference?
  17. use const references where appropriate a9ac95c1bc
  18. Diapolo commented at 5:36 pm on June 4, 2015: none
    @laanwj Fixed 2 merge conflicts, one in rpcnet.cpp and the other in utilstrencodings.cpp and added getValStr(). Should be ready.
  19. laanwj merged this on Jun 5, 2015
  20. laanwj closed this on Jun 5, 2015

  21. laanwj referenced this in commit 3fce72eaa3 on Jun 5, 2015
  22. Diapolo deleted the branch on Jun 5, 2015
  23. zkbot referenced this in commit df07f9ad23 on Feb 15, 2017
  24. zkbot referenced this in commit ec069ce96c on Mar 3, 2017
  25. zkbot referenced this in commit 702eefc71a on Mar 3, 2017
  26. zkbot referenced this in commit 99c4c6de0c on Mar 3, 2017
  27. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

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-12-19 00:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me