-
Notifications
You must be signed in to change notification settings - Fork 38.7k
refactor: Remove redundant c_str() calls in formatting #17279
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
Our formatter, tinyformat, *never* needs `c_str()` for strings. Remove redundant `c_str()` calls for: - `strprintf` - `LogPrintf` - `tfm::format`
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
Looks like there is still a usage of Line 1412 in 1ab6c12
|
|
That one is special: it adds a prefix to the format string, which is a |
|
Concept ACK: nice cleanup |
|
Code review ACK c72906d. Easy to review with |
|
ACK, the args are: |
…atting c72906d refactor: Remove redundant c_str() calls in formatting (Wladimir J. van der Laan) Pull request description: Our formatter, tinyformat, *never* needs `c_str()` for strings. Still, many places call it redundantly, resulting in longer code and a slight overhead. Remove redundant `c_str()` calls for: - `strprintf` - `LogPrintf` - `tfm::format` (also, combined with bitcoin#17095, I think this improves logging in case of unexpected embedded NULL characters) ACKs for top commit: ryanofsky: Code review ACK c72906d. Easy to review with `git log -p -n1 --word-diff-regex=. -U0 c72906d` Tree-SHA512: 9e21e7bed8aaff59b8b8aa11571396ddc265fb29608c2545b1fcdbbb36d65b37eb361db6688dd36035eab0c110f8de255375cfda50df3d9d7708bc092f67fefc
|
Can we make it a compile time error to pass c-strings in to format? Passing them in should never be necessary. |
Oh, I guess that is not true. One might want to print |
I don't think this is possible, as a function that only takes |
Summary: Our formatter, tinyformat, *never* needs `c_str()` for strings. Remove redundant `c_str()` calls for: - `strprintf` - `LogPrintf` - `tfm::format` This is a backport of Core [[bitcoin/bitcoin#17279 | PR17279]] Test Plan: ninja all check Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D5908
Our formatter, tinyformat, never needs
c_str()for strings. Still, many places call it redundantly, resulting in longer code and a slight overhead.Remove redundant
c_str()calls for:strprintfLogPrintftfm::format(also, combined with #17095, I think this improves logging in case of unexpected embedded NULL characters)