Change hardcoded character constants to descriptive named constants for db keys #5707

pull Earlz wants to merge 1 commits into bitcoin:master from Earlz:master changing 1 files +32 −21
  1. Earlz commented at 3:31 PM on January 25, 2015: contributor

    This change makes it so that all the magical constants used as database keys like 'b' are actually self-describing. I tried to make it obvious when a key is only suppose to have 1 value in the database (opposed to many).

  2. sipa commented at 3:36 PM on January 25, 2015: member

    This changes the prefix bytes into prefix ints. Ideally you'd mark the enum as char, but that's not valid C++98 (and we can't use C++11 due to compatibility reasons yet), so for now you'll have to stick with a list of constants rather than making it an enum.

  3. change hardcoded character constants to a set of descriptive named constants for database keys 14d023f1ae
  4. Earlz force-pushed on Jan 25, 2015
  5. Earlz commented at 3:59 PM on January 25, 2015: contributor

    Alrght, I changed it to use static const char and rebased it into the commit

  6. Earlz renamed this:
    Change hardcoded character constants to a descriptive enum for db keys
    Change hardcoded character constants to descriptive constants for db keys
    on Jan 25, 2015
  7. Earlz renamed this:
    Change hardcoded character constants to descriptive constants for db keys
    Change hardcoded character constants to descriptive named constants for db keys
    on Jan 25, 2015
  8. laanwj added the label Improvement on Jan 26, 2015
  9. laanwj commented at 10:14 AM on January 26, 2015: member

    I expected this to result in the same binary, but it doesn't. What appears to happen is that in 40e96a3 it puts the character in a local buffer on the stack, whereas in 14d023f it uses the address of the constant. This makes sense as it passes a reference (pointer).

    In any case, I did a verification in which I replaced the constants with #defines, and that one matched.

    I also did rudimentary testing to make sure this doesn't result in a different on-disk format. So ACK.

  10. laanwj merged this on Jan 31, 2015
  11. laanwj closed this on Jan 31, 2015

  12. laanwj referenced this in commit 6af674ecdc on Jan 31, 2015
  13. random-zebra referenced this in commit 73d26f20e9 on May 27, 2020
  14. DrahtBot locked this on Sep 8, 2021
Contributors

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-13 21:15 UTC

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