DecodeHexBlk and DecodeHexBlockHeader have exactly the same implementation, except that they decode a CBlock and CBlockHeader object, respectively. Thus we can share the common code through a template.
Simple refactoring: Common code for decoding of hex "objects" #14009
pull domob1812 wants to merge 1 commits into bitcoin:master from domob1812:refactor-hex-decode changing 1 files +16 −18-
domob1812 commented at 12:37 PM on August 20, 2018: contributor
-
b9a19f3229
Common code for decoding of hex "objects".
DecodeHexBlk and DecodeHexBlockHeader have exactly the same implementation, except that they decode a CBlock and CBlockHeader object, respectively. Thus we can share the common code through a template.
-
domob1812 commented at 12:39 PM on August 20, 2018: contributor
In my opinion, this make the code easier to read and maintain (by avoiding duplication) - but of course there might be an argument that templates should be used sparingly and only where absolutely necessary. But I think this use does not introduce any complexity for readers of the code, as it is immediately next to the only usages.
- fanquake added the label Refactoring on Aug 20, 2018
- jonasschnelli approved
-
jonasschnelli commented at 2:35 PM on August 20, 2018: contributor
utACK b9a19f32290119f225f7769ba1432fa7904011b3
-
practicalswift commented at 6:09 PM on August 20, 2018: contributor
utACK b9a19f32290119f225f7769ba1432fa7904011b3
-
promag commented at 11:58 PM on August 20, 2018: member
The template is not that long, and it's only instanced twice. Not sure if it's worth it.
utACK b9a19f3 anyway.
-
laanwj commented at 3:11 PM on August 22, 2018: member
~0 on this, it factors out code but also saves only two lines
-
laanwj commented at 8:47 AM on August 31, 2018: member
Closing this, I don't think this is worth making a change to the code, sorry
- laanwj closed this on Aug 31, 2018
- domob1812 deleted the branch on Aug 31, 2018
-
domob1812 commented at 9:22 AM on August 31, 2018: contributor
No worries
- DrahtBot locked this on Sep 8, 2021
Contributors
Labels