Simplify "bool x = y ? true : false". Remove unused function and trailing semicolon. #10553

pull practicalswift wants to merge 3 commits into bitcoin:master from practicalswift:minor-cleanups changing 5 files +7 −8
  1. practicalswift commented at 8:48 AM on June 8, 2017: contributor

    Three minor cleanups:

    • Simplify bool x = y ? true : false to bool x = y
    • Remove unused function InsecureRandBytes(size_t len)
    • Remove accidental trailing semicolon
  2. [tests] Remove unused function InsecureRandBytes(size_t len) 30c2d9db48
  3. [tests] Remove accidental trailing semicolon 9f841a6c3d
  4. fanquake added the label Refactoring on Jun 8, 2017
  5. practicalswift force-pushed on Jun 8, 2017
  6. dcousens approved
  7. achow101 commented at 9:01 PM on June 8, 2017: member

    utACK a65124bc44515c60e13e74ec83f6adbb8cc48a68

  8. paveljanik commented at 11:49 AM on June 9, 2017: contributor

    utACK a65124b

  9. fanquake commented at 1:47 PM on June 9, 2017: member

    utACK a65124b

  10. Simplify "bool x = y ? true : false" to "bool x = y" 67ca816849
  11. in src/rpc/misc.cpp:215 in a65124bc44 outdated
     211 | @@ -212,8 +212,8 @@ UniValue validateaddress(const JSONRPCRequest& request)
     212 |  
     213 |  #ifdef ENABLE_WALLET
     214 |          isminetype mine = pwallet ? IsMine(*pwallet, dest) : ISMINE_NO;
     215 | -        ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false));
     216 | -        ret.push_back(Pair("iswatchonly", (mine & ISMINE_WATCH_ONLY) ? true: false));
     217 | +        ret.push_back(Pair("ismine", static_cast<bool>(mine & ISMINE_SPENDABLE)));
    


    laanwj commented at 12:45 PM on June 11, 2017:

    Wouldn't simply bool(mine & ISMINE_SPENDABLE) work? I don't think we really want to re-interpret the value as a bool here, but instantiate a bool with the value !=0. I know static_cast doesn't reinterpret values, but it seems ugly... Speaking of which, this could even be (mine & ISMINE_SPENDABLE) != 0?

  12. practicalswift force-pushed on Jun 11, 2017
  13. practicalswift commented at 1:46 PM on June 11, 2017: contributor

    @laanwj Good point! Now using the suggested bool(mine & ISMINE_SPENDABLE) form.

  14. sipa commented at 9:59 PM on June 12, 2017: member

    utACK 67ca816849d0aa292a138e6c08edafd17ad6a948

  15. laanwj merged this on Jun 13, 2017
  16. laanwj closed this on Jun 13, 2017

  17. laanwj referenced this in commit 303c171b94 on Jun 13, 2017
  18. PastaPastaPasta referenced this in commit a42944e02c on Jul 5, 2019
  19. PastaPastaPasta referenced this in commit 8d7ed2f0ac on Jul 5, 2019
  20. PastaPastaPasta referenced this in commit 9f9f663ace on Jul 6, 2019
  21. PastaPastaPasta referenced this in commit 609cd8fec1 on Jul 8, 2019
  22. PastaPastaPasta referenced this in commit 0284ee1a22 on Jul 9, 2019
  23. PastaPastaPasta referenced this in commit eef9c8ea15 on Jul 9, 2019
  24. barrystyle referenced this in commit 66f4cb951f on Jan 22, 2020
  25. practicalswift deleted the branch on Apr 10, 2021
  26. DrahtBot locked this on Aug 18, 2022

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-16 15:15 UTC

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