-
Notifications
You must be signed in to change notification settings - Fork 38.7k
util: Remove [U](BEGIN|END) macros #15139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Replace use of `BEGIN` and `END` macros on uint256 with `begin()` and `end()` methods in the Merkle tree code.
Unfortunately, `std::string` elements are (bare) chars. As these are the most likely type to be passed to these functions, make them use char instead of unsigned char. This avoids some casts.
f29ea07 to
332b3dd
Compare
|
utACK 332b3dd - could squash the first two |
|
utACK 332b3dd |
|
utACK 332b3dd. |
|
utACK |
332b3dd util: Make ToLower and ToUpper take a char (Wladimir J. van der Laan) edb5bb3 util: remove unused [U](BEGIN|END) macros (Wladimir J. van der Laan) 7fa238c Replace use of BEGIN and END macros on uint256 (Wladimir J. van der Laan) Pull request description: Two cleanups in `util/strencodings.h`: - Remove `[U](BEGIN|END)` macros — The only use of these was in the Merkle tree code with `uint256` which has its own `begin` and `end` methods which are better. - Make ToLower and ToUpper take a char — Unfortunately, `std::string` elements are (bare) chars. As these are the most likely type to be passed to these functions, make them use char instead of unsigned char. This avoids some casts. Tree-SHA512: 96c8292e1b588d3d7fde95c2e98ad4e7eb75e7baab40a8e8e8209d4e8e7a1bd3b6846601d20976be34a9daabefc50cbc23f3b04200af17d0dfc857c4ec42aca7
| void Downcase(std::string& str) | ||
| { | ||
| std::transform(str.begin(), str.end(), str.begin(), [](unsigned char c){return ToLower(c);}); | ||
| std::transform(str.begin(), str.end(), str.begin(), [](char c){return ToLower(c);}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just realizing that it's passing a silly identity function:
std::transform(str.begin(), str.end(), str.begin(), ToLower);Anyhow, not going to file a PR for just that, I guess the compiler optimizes this away, maybe someone touching this code in the future can take it into account.
Summary: Replace use of `BEGIN` and `END` macros on uint256 with `begin()` and `end()` methods in the Merkle tree code. --- bitcoin/bitcoin@7fa238c Partial backport of Core [[bitcoin/bitcoin#15139 | PR15139]] Test Plan: ninja check-all Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D6288
Summary: bitcoin/bitcoin@edb5bb3 --- Partial backport of Core [[bitcoin/bitcoin#15139 | PR15139]] Test Plan: ninja check Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D6292
Summary: Unfortunately, `std::string` elements are (bare) chars. As these are the most likely type to be passed to these functions, make them use char instead of unsigned char. This avoids some casts. bitcoin/bitcoin@332b3dd --- Depends on D6294 Concludes backport of Core [[bitcoin/bitcoin#15139 | PR15139]] Test Plan: ninja check Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Subscribers: deadalnix Differential Revision: https://reviews.bitcoinabc.org/D6295
Summary: Replace use of `BEGIN` and `END` macros on uint256 with `begin()` and `end()` methods in the Merkle tree code. --- bitcoin/bitcoin@7fa238c Partial backport of Core [[bitcoin/bitcoin#15139 | PR15139]] Test Plan: ninja check-all Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D6288
332b3dd util: Make ToLower and ToUpper take a char (Wladimir J. van der Laan) edb5bb3 util: remove unused [U](BEGIN|END) macros (Wladimir J. van der Laan) 7fa238c Replace use of BEGIN and END macros on uint256 (Wladimir J. van der Laan) Pull request description: Two cleanups in `util/strencodings.h`: - Remove `[U](BEGIN|END)` macros — The only use of these was in the Merkle tree code with `uint256` which has its own `begin` and `end` methods which are better. - Make ToLower and ToUpper take a char — Unfortunately, `std::string` elements are (bare) chars. As these are the most likely type to be passed to these functions, make them use char instead of unsigned char. This avoids some casts. Tree-SHA512: 96c8292e1b588d3d7fde95c2e98ad4e7eb75e7baab40a8e8e8209d4e8e7a1bd3b6846601d20976be34a9daabefc50cbc23f3b04200af17d0dfc857c4ec42aca7
332b3dd util: Make ToLower and ToUpper take a char (Wladimir J. van der Laan) edb5bb3 util: remove unused [U](BEGIN|END) macros (Wladimir J. van der Laan) 7fa238c Replace use of BEGIN and END macros on uint256 (Wladimir J. van der Laan) Pull request description: Two cleanups in `util/strencodings.h`: - Remove `[U](BEGIN|END)` macros — The only use of these was in the Merkle tree code with `uint256` which has its own `begin` and `end` methods which are better. - Make ToLower and ToUpper take a char — Unfortunately, `std::string` elements are (bare) chars. As these are the most likely type to be passed to these functions, make them use char instead of unsigned char. This avoids some casts. Tree-SHA512: 96c8292e1b588d3d7fde95c2e98ad4e7eb75e7baab40a8e8e8209d4e8e7a1bd3b6846601d20976be34a9daabefc50cbc23f3b04200af17d0dfc857c4ec42aca7
Two cleanups in
util/strencodings.h:[U](BEGIN|END)macros — The only use of these was in the Merkle tree code withuint256which has its ownbeginandendmethods which are better.std::stringelements are (bare) chars. As these are the most likely type to be passed to these functions, make them use char instead of unsigned char. This avoids some casts.