Avoid unused locals for CScript::IsWitnessProgram#12938
Avoid unused locals for CScript::IsWitnessProgram#12938Empact wants to merge 1 commit intobitcoin:masterfrom
Conversation
e8b04fb to
b9f0169
Compare
|
utACK b9f0169bcce3ca7c9d0646ddda5bf264062be87b Nice simplification |
There was a problem hiding this comment.
Might as well return this directly.
There was a problem hiding this comment.
I like that style too, but held back for the sake of simplifying review. Here's my choice if I'm to simplify the method:
static constexpr bool IsOP_N(const unsigned char op)
{
return (op == OP_0 || (op >= OP_1 && op <= OP_16));
}
// A witness program is any valid CScript that consists of a 1-byte push opcode
// followed by a data push between 2 and 40 bytes.
bool CScript::IsWitnessProgram() const
{
return ((this->size() >= 4 && this->size() <= 42) &&
IsOP_N((*this)[0]) &&
(size_t)((*this)[1] + 2) == this->size());
}Incidentally, this matches the style of IsPayToWitnessScriptHash and IsPayToScriptHash, above. Thoughts?
1bc4896 to
e953c69
Compare
|
Rebased, squashed, and updated to take advantage of |
588e930 to
9057444
Compare
|
I am generally a concept NACK on changes like this; IMO the review burden for refactoring consensus-critical code typically outweighs the benefits. |
For those cases where the version and program are not useful.
9057444 to
943f3b7
Compare
Agree, seems to risky, closing. |
For those cases where the version and program are not useful.