[trivial] Add missing const qualifiers. #7977

pull domob1812 wants to merge 1 commits into bitcoin:master from domob1812:consts changing 3 files +4 −4
  1. domob1812 commented at 11:22 AM on April 30, 2016: contributor

    Add some const qualifiers to references that are not modified and should be marked as const.

  2. MarcoFalke added the label Refactoring on Apr 30, 2016
  3. [trivial] Add missing const qualifiers.
    Add some const qualifiers to references that are not modified and should
    be marked as const.
    f7c4f79f07
  4. in src/txmempool.h:None in 1a7539b7fc outdated
     671 | @@ -672,10 +672,10 @@ class CTxMemPool
     672 |  class CCoinsViewMemPool : public CCoinsViewBacked
     673 |  {
     674 |  protected:
     675 | -    CTxMemPool &mempool;
     676 | +    const CTxMemPool &mempool;
     677 |  
     678 |  public:
     679 | -    CCoinsViewMemPool(CCoinsView *baseIn, CTxMemPool &mempoolIn);
     680 | +    CCoinsViewMemPool(CCoinsView *baseIn, const CTxMemPool &mempoolIn);
    


    MarcoFalke commented at 4:17 PM on April 30, 2016:

    nit: If you do trivial fixes, please also do all other trivial fixes in the same line:

    diff --git a/src/main.cpp b/src/main.cpp
    index ed34137..2777245 100644
    --- a/src/main.cpp
    +++ b/src/main.cpp
    @@ -1471 +1471 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, const Consensus::P
    -            const CCoinsViewCache &view = *pcoinsTip;
    +            const CCoinsViewCache& view = *pcoinsTip;
    diff --git a/src/txmempool.h b/src/txmempool.h
    index c991514..d17e332 100644
    --- a/src/txmempool.h
    +++ b/src/txmempool.h
    @@ -675 +675 @@ protected:
    -    const CTxMemPool &mempool;
    +    const CTxMemPool& mempool;
    @@ -678 +678 @@ public:
    -    CCoinsViewMemPool(CCoinsView *baseIn, const CTxMemPool &mempoolIn);
    +    CCoinsViewMemPool(CCoinsView* baseIn, const CTxMemPool& mempoolIn);
    

    domob1812 commented at 4:37 PM on April 30, 2016:

    I agree but was not aware that there is a general style preference of uint256& hash over uint256 &hash. I personally like the former better, but did not want to reformat "someone else's" code. Is the former explicitly preferred in Bitcoin sources? (Which are not always consistent in style.)


    MarcoFalke commented at 5:17 PM on April 30, 2016:

    It is not really important to get every white space "correct" but you can read about the general preferred code style over here: https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#developer-notes


    domob1812 commented at 5:27 PM on April 30, 2016:

    Thanks for the heads-up, I've updated the patch now. This is not explicitly mentioned in the doc, but the example code block uses the uint256& hash style.


    MarcoFalke commented at 5:33 PM on April 30, 2016:

    If you don't want to do that manually, you can just do $ git diff HEAD~ -U0|cfd. Where cfd is an alias for ./contrib/devtools/clang-format-diff.py -p1 -i -v.

  5. domob1812 force-pushed on Apr 30, 2016
  6. dcousens commented at 1:18 AM on May 2, 2016: contributor

    utACK f7c4f79

  7. MarcoFalke commented at 11:01 AM on May 2, 2016: member

    utACK f7c4f79

  8. laanwj merged this on May 5, 2016
  9. laanwj closed this on May 5, 2016

  10. laanwj referenced this in commit e8d917591f on May 5, 2016
  11. domob1812 deleted the branch on May 5, 2016
  12. codablock referenced this in commit 38e5e8ee93 on Sep 16, 2017
  13. codablock referenced this in commit 6a4cc3ef4e on Sep 19, 2017
  14. codablock referenced this in commit f8ad2ffa79 on Dec 20, 2017
  15. DrahtBot 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-04-21 18:15 UTC

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