-
Notifications
You must be signed in to change notification settings - Fork 38.7k
refactor: Replace const char* to std::string #19004
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
|
Concept ACK. It would be nice to motivate the change in the opening post a bit:
|
Thanks for the comment! Added those bits in the post |
|
Also you can leave out the listing of files that you changed and what changes you made to those files. This is clear from reading the diff/looking at the changed files. |
Ok. Should I take those out or just note for future PRs? |
|
Both a suggestion for future PRs as well as this one, because the pull request description will end up in the merge commit, if this is merged. |
|
Done :) |
practicalswift
left a comment
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.
Concept ACK modulo nits
Welcome as a contributor @kcalvinalvin :)
|
Concept ACK. |
81d847c to
a0da974
Compare
|
Addressed |
a0da974 to
23610aa
Compare
|
It's unfortunate to make these functions return an |
|
All callers put the return value into a string anyway. So return value optimization (or whatever it is called) should take care of this and make it a no-op, no? Going forward, with C++17 they can be made constexpr string views if performance is really a concern. |
|
Concept ACK |
|
@MarcoFalke That's a good point - this PR isn't making anything worse in that case. It could be improved later, but no need add extra complexity for that now. |
23610aa to
bdd9cb6
Compare
hebasto
left a comment
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.
ACK bdd9cb6a9bc314400ad655a45ee32e03756468d1, compiled on Linux Mint 19.3 with GCC and Clang.
|
ACK bdd9cb6a9bc314400ad655a45ee32e03756468d1 🥑 Show signature and timestampSignature: Timestamp of file with hash |
|
ACK on the changes. Can you please reformat your commit message though to put an empty line between the title and the body? Tools such as |
... and replace |
Some functions should be returning std::string instead of const char*. This commit changes that.
bdd9cb6 to
c57f03c
Compare
Done :)
Also Done :) Also changed the GitHub PR title from |
hebasto
left a comment
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.
re-ACK c57f03c
|
re-ACK c57f03c (no changes since previous review) 🚃 Show signature and timestampSignature: Timestamp of file with hash |
|
~0 I like all of these except |
|
Given that none of the call sites checked for nullptr of the char array, I'd find it very dangerous to re-introduce this sharp edge. Also for optional return values, we generally use Optional. In any case, I think this can be discussed in a follow-up pull request. |
|
Fair enough, Code Review ACK c57f03c |
|
ACK c57f03c -- patch looks correct |
c57f03c refactor: Replace const char* to std::string (Calvin Kim) Pull request description: Rationale: Addresses bitcoin#19000 Some functions should be returning std::string instead of const char*. This commit changes that. Main benefits/reasoning: 1. The functions never return nullptr, so returning a string makes code at call sites easier to review (reviewers don't have to read the source code to verify that a nullptr is never returned) 2. All call sites convert to string anyway ACKs for top commit: MarcoFalke: re-ACK c57f03c (no changes since previous review) 🚃 Empact: Fair enough, Code Review ACK bitcoin@c57f03c practicalswift: ACK c57f03c -- patch looks correct hebasto: re-ACK c57f03c Tree-SHA512: 9ce99bb38fe399b54844315048204cafce0f27fd8f24cae357fa7ac6f5d8094d57bbf5f5c1f5878a65f2d35e4a3f95d527eb17f49250b690c591c0df86ca84fd
Summary: ``` Some functions should be returning std::string instead of const char*. This commit changes that. ``` Backport of core [[bitcoin/bitcoin#19004 | PR19004]]. Test Plan: ninja all check-all Reviewers: #bitcoin_abc, PiRK Reviewed By: #bitcoin_abc, PiRK Differential Revision: https://reviews.bitcoinabc.org/D9124
Rationale: Addresses #19000
Some functions should be returning std::string instead of const char*.
This commit changes that.
Main benefits/reasoning: