Removing some implicit conversions #1784

pull xanatos wants to merge 1 commits into bitcoin:master from xanatos:patch-16 changing 1 files +1 −1
  1. xanatos commented at 1:31 PM on September 4, 2012: none

    I think that implicitly converting 3 (the number) to uint256, doing an & between two uint256 and finally comparing the result to an uint64 (the 0) is a little overkill if all you want is to check 2 bits of an uint256. I have to say the truth, I'm not sure if now we would be comparing the "same" 2 bits or the 2 bits from the other side of the uint256 (looking at operator= and Get64 I would say the same), but considering what this code wants to obtain, it shouldn't be a problem.

    (I'm not even sure if this code will be faster, but I do think that all those implicit conversions are b.a.d.). We could even do a (*hashrand.begin() & 3) but that would be quite unreadable.

  2. Removing some implicit conversions
    I think that implicitly converting 3 (the number) to uint256, doing an & between two uint256 and finally comparing the result to an uint64 (the 0) is a little overkill if all you want is to check 2 bits of an uint256. 
    I have to say the truth, I'm not sure if now we would be comparing the "same" 2 bits or the 2 bits from the other side of the uint256 (looking at operator= and Get64 I would say the same), but considering what this code wants to obtain, it shouldn't be a problem.
    
    (I'm not even sure if this code will be faster, but I do think that all those implicit conversions are b.a.d.). We could even do a (*hashrand.begin() & 3) but that would be quite unreadable.
    5fb61b7af9
  3. gavinandresen commented at 1:39 PM on September 4, 2012: contributor

    NACK.

    I am against this type of nit-pick. There is a fixed cost to ANY change proposed, and if the benefit of the change is not greater than that fixed cost then the change is nothing but a denial-of-service attack on our collective attention.

  4. laanwj commented at 3:06 PM on September 4, 2012: member

    In general, nitpick pull requests means that people are looking closely at the code and reporting issues and strange things, which is very good.

    This, of course, doesn't all proposed changes have to be accepted. In this case I agree with @gavinandresen. This makes the code longer, not shorter :p

  5. jgarzik commented at 3:12 PM on September 4, 2012: contributor

    Agreed, closing

  6. jgarzik closed this on Sep 4, 2012

  7. owlhooter referenced this in commit 837c4fc5de on Oct 10, 2018
  8. 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-29 03:16 UTC

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