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

    No description provided.

  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:None 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. Diapolo cross-referenced this on Jun 2, 2015 from issue Policy: Create CPolicy interface and CStandardPolicy class implementing it by jtimon
  16. fanquake commented at 2:48 PM on June 3, 2015: member

    utACK

  17. 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?

  18. use const references where appropriate a9ac95c1bc
  19. 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.

  20. laanwj merged this on Jun 5, 2015
  21. laanwj closed this on Jun 5, 2015

  22. laanwj referenced this in commit 3fce72eaa3 on Jun 5, 2015
  23. Diapolo deleted the branch on Jun 5, 2015
  24. str4d cross-referenced this on Feb 14, 2017 from issue Bitcoin 0.12 misc PRs 1 by str4d
  25. zkbot referenced this in commit df07f9ad23 on Feb 15, 2017
  26. zkbot referenced this in commit ec069ce96c on Mar 3, 2017
  27. zkbot referenced this in commit 702eefc71a on Mar 3, 2017
  28. zkbot referenced this in commit 99c4c6de0c on Mar 3, 2017
  29. bitcoin 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: 2026-05-20 06:55 UTC