-
Notifications
You must be signed in to change notification settings - Fork 37.8k
refactor: modernize recent ByteType
usages and read/write functions
#31601
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
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31601. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. |
ByteType
usages and simplify read/write functionsByteType
usages and simplify read/write functions
ByteType
usages and simplify read/write functionsByteType
usages and read/write functions
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.
Code review ACK 9908ab0
Good to get rid of a few redundant UCharCasts
.
Not sure about the first commit. There is no issue or risk with the existing code that is fixed by the style fixups, so to me it seems better to not change it, unless there is a compelling reason. Generally when it comes to style modernizations, my recommendation would be to include them in changes that touch the line anyway, or leave them as-is, or do them wholesale for the whole project (only if there is a good reason for them). But going out and doing them one-by one for specific subsections of the code, especially if the rationale for the change is "consistency" may not be a net benefit. |
Also, for the second commit, it may be helpful to add the commit since the change is possible, like I did in f23d6a5, where I presume it is cherry-picked from? |
I haven't seen your commit @maflcko, I've recreated it - do you want me to cherry-pick that here instead? |
It is already part of https://github.com/bitcoin/bitcoin/pull/31519/commits and I am not sure if it is relevant enough to be split up |
If other reviewers think it's relevant enough we can simplify that draft PR of yours to focus on Spans. |
Agree with this. I don't have an issue with any of the individual changes in the first commit, but most of them would apply all over the codebase. And doing that all over would be a recipe for never-ending churn. So unless the compiled output for the first commit looks any different, I'd rather not be doing random opinionated changes like this. |
9908ab0
to
bf5baae
Compare
Isn't that what we're doing regularly though? Endlessly making the legacy codebase a tiny bit more readable, a tiny bit more modern, a tiny bit more maintainable and consistent?
Previously, I've applied the following changes (as mentioned in the commit message), but I agree that a few of these could be reverted as being indeed opinionated:
|
|
Not change for change's sake, no. Please consider this from the POV of reviewers and maintainers. A constant stream of changes like that is exhausting. It would distract from larger improvements. I think @maflcko's comment above is a good description of the culture of this project: modernize the code when you touch it, and if it's important enough to apply to the rest of the codebase, do it in one shot and be done with it. We (and bots) could fill endless PRs with things that make things a tiny bit more modern/maintainable/consistent, but we don't for the sake of the sanity of our peers. |
This PR was a follow-up from the comments on Marco's change. |
|
It's not purely a stylistic change - it clarifies which parameter remains unchanged (i.e., it isn’t a "return value"). It seems there’s a strong preference against this change, so I don't mind adjusting the approach or closing the PR altogether. |
If there is a good reason to use |
- Replaced `unsigned char` in `ByteType` concept with `uint8_t` for consistency. - Used a single `ByteType auto*` parameter to reduce template boilerplate, as suggested by Russ. Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
bf5baae
to
e97519f
Compare
I'm not sure these arguments would hold in other cases (i.e. "no compiler safety needed since the tests would fail otherwise"), but I've removed the consts as well, basically only leaving @ryanofsky's changes. |
The example holds also for the template: Externally they are exactly the same, so they could at most affect the function body, which is 2 or 3 lines. I just don't see what type of issue the change is trying to prevent, or what benefit it brings to developers or users. (For reference, the commit that drops the unused casts (f23d6a5) has already been merged.) |
Follow-up to #31524, applying a few of the review suggestions to the affected code, while enabling more trivial reads/writes to use the new
std::byte
interface.