Initialize members in initialization lists. Prefer in-class initializers to member initializers in constructors for constant initializers.
Rationale:
Initialize members in initialization lists. Prefer in-class initializers to member initializers in constructors for constant initializers.
Rationale:
<!--e57a25ab6845829454e8d69fc972939a-->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.
21 | - scriptSig = scriptSigIn; 22 | - nSequence = nSequenceIn; 23 | } 24 | 25 | -CTxIn::CTxIn(uint256 hashPrevTx, uint32_t nOut, CScript scriptSigIn, uint32_t nSequenceIn) 26 | +CTxIn::CTxIn(uint256 hashPrevTx, uint32_t nOut, CScript scriptSigIn, uint32_t nSequenceIn) : prevout(COutPoint(hashPrevTx, nOut)), scriptSig(scriptSigIn), nSequence(nSequenceIn)
Could put a \n before the : to avoid having excessively long lines, no? (Feddback also applies to other places with long lines)
@MarcoFalke Good point! Newlines added. Please re-review :-)
Concept ACK.
4356 | +CKeyPool::CKeyPool(const CPubKey& vchPubKeyIn, bool internalIn) : vchPubKey(vchPubKeyIn), fInternal(internalIn) 4357 | { 4358 | nTime = GetTime(); 4359 | - vchPubKey = vchPubKeyIn; 4360 | - fInternal = internalIn; 4361 | m_pre_split = false;
nit: this one too?
255 | @@ -256,7 +256,8 @@ class CScriptVisitor : public boost::static_visitor<bool> 256 | private: 257 | CScript *script; 258 | public: 259 | - explicit CScriptVisitor(CScript *scriptin) { script = scriptin; } 260 | + explicit CScriptVisitor(CScript *scriptin) : script(scriptin) { 261 | + }
nit: whitespace
@Empact Where do you want the whitespace added/removed? :-)
Probably leave everything in a single line?
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.
Could also apply to CompareInvMempoolOrder, FreespaceChecker, etc.
@Empact Thanks for reviewing. Feedback addressed. Please re-review :-)
Some of these initializers (those with constant values) could move to the class declaration itself
@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 filterInventoryKnown.reset() has been removed. That looks correct, right?
Also added a developer note: "Prefer initialization to assignment in constructors"