-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Prefer initialization to assignment in constructors. Prefer in-class initializers to member initializers in constructors for constant initializers. #13766
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
Reviewers, 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. |
src/primitives/transaction.cpp
Outdated
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.
Could put a \n before the : to avoid having excessively long lines, no? (Feddback also applies to other places with long lines)
b61c902 to
5e80e93
Compare
|
@MarcoFalke Good point! Newlines added. Please re-review :-) |
|
Concept ACK. |
src/wallet/wallet.cpp
Outdated
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.
nit: this one too?
src/script/standard.cpp
Outdated
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.
nit: whitespace
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.
@Empact Where do you want the whitespace added/removed? :-)
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.
Probably leave everything in a single line?
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.
clang-format-diff.py accepts at least:
explicit CScriptVisitor(CScript* scriptin) : script(scriptin) {}
explicit CScriptVisitor(CScript* scriptin) : script(scriptin)
{
}
For an empty set, like Marco I like the former.
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.
Could also apply to CompareInvMempoolOrder, FreespaceChecker, etc.
915e75a to
871d81c
Compare
|
@Empact Thanks for reviewing. Feedback addressed. Please re-review :-) |
|
Some of these initializers (those with constant values) could move to the class declaration itself |
2a2f614 to
eefb1b1
Compare
27c71db to
261a470
Compare
261a470 to
6ee270e
Compare
|
@laanwj Now preferring in-class initializers to member initializers in constructors for constant initializers. Please re-review the PR. Please note that a redundant call to |
6ee270e to
5ff5fa7
Compare
|
Also added a developer note: "Prefer initialization to assignment in constructors" |
5ff5fa7 to
157ab56
Compare
Initialize members in initialization lists. Prefer in-class initializers to member initializers in constructors for constant initializers.
Rationale: