diff options
author | Ryan Ofsky <ryan@ofsky.org> | 2024-04-02 10:11:24 -0400 |
---|---|---|
committer | Ryan Ofsky <ryan@ofsky.org> | 2024-04-02 10:47:05 -0400 |
commit | 3b987d03a49964995dced76889634561fd363d28 (patch) | |
tree | af04f8a8d7ceaf673bd1c695646ce9716dd4d15c /contrib | |
parent | 6dabb315c4fb2cdc4421ed34dee5e19042f899c3 (diff) | |
parent | b0344c219a641b759fb0cc4f53afebe675b8ca27 (diff) | |
download | bitcoin-3b987d03a49964995dced76889634561fd363d28.tar.xz |
Merge bitcoin/bitcoin#29419: log: deduplicate category names and improve logging.cpp
b0344c219a641b759fb0cc4f53afebe675b8ca27 logging: remove unused BCLog::UTIL (Vasil Dimov)
d3b3af90343b7671231afd7dff87e87ff86d31d7 log: deduplicate category names and improve logging.cpp (Vasil Dimov)
Pull request description:
The code in `logging.cpp` needs to:
* Get the category name given the flag (e.g. `BCLog::PRUNE` -> `"prune"`)
* Get the flag given the category name (e.g. `"prune"` -> `BCLog::PRUNE`)
* Get the list of category names sorted in alphabetical order
Achieve this by using the proper std containers. The result is
* less code (the diff of the first commit is +62 / -129)
* faster code (to linear search and no copy+sort)
* more maintainable code (the categories are no longer duplicated in `LogCategories[]` and `LogCategoryToStr()`)
This behavior is preserved:
`BCLog::NONE` -> `""` (lookup by `LogCategoryToStr()`)
`""` -> `BCLog::ALL` (lookup by `GetLogCategory("")`)
---
Also remove unused `BCLog::UTIL`.
---
These changes (modulo the `BCLog::UTIL` removal) are part of https://github.com/bitcoin/bitcoin/pull/29415 but they make sense on their own and would be good to have them, regardless of the fate of https://github.com/bitcoin/bitcoin/pull/29415. Also, if this is merged, that would reduce the size of https://github.com/bitcoin/bitcoin/pull/29415, thus the current standalone PR.
ACKs for top commit:
davidgumberg:
crACK https://github.com/bitcoin/bitcoin/pull/29419/commits/b0344c219a641b759fb0cc4f53afebe675b8ca27
pinheadmz:
ACK b0344c219a641b759fb0cc4f53afebe675b8ca27
ryanofsky:
Code review ACK b0344c219a641b759fb0cc4f53afebe675b8ca27. Nice cleanup! Having to maintain multiple copies of the same mapping seemed messy and a like a possible footgun. I checked old and new mappings in both directions and confirmed no behavior should be changing.
Tree-SHA512: 57f87a090932f9b33dc8e075d1855dba9b71a3243a0758511745483dec2d9c46d3b532eadab297e78164c9b7caba370986ee380696a45f0778a841082f8e21a7
Diffstat (limited to 'contrib')
0 files changed, 0 insertions, 0 deletions