refactor(miniscript): Move keys to avoid copy
What changed, and why it matters
This is a tiny C++ performance cleanup in Bitcoin Core's miniscript code. It changes one constructor to move a list of keys instead of copying them, matching how other arguments are already handled. There is no security issue here.
No security action needed. Treat as a normal code-quality refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit changes a single constructor in src/script/miniscript.h from keys(key) to keys(std::move(key)), making the keys vector moved rather than copied. This is a non-functional refactor that avoids an unnecessary copy and aligns with the existing pattern used for subs and data in the same initializer list. It only affects the private Clone() constructor path.
Changed components
src/script/miniscript.h private Node constructor used by Clone()Inspect captured patch +1 / −1
diff --git a/src/script/miniscript.h b/src/script/miniscript.h
index 1b7e84f4..a65900c7 100644
--- a/src/script/miniscript.h
+++ b/src/script/miniscript.h
@@ -607,7 +607,7 @@ private:
// This is kept private as no valid fragment has all of these arguments.
// Only used by Clone()
Node(internal::NoDupCheck, MiniscriptContext script_ctx, enum Fragment nt, std::vector<Node> sub, std::vector<Key> key, std::vector<unsigned char> arg, uint32_t val)
- : fragment(nt), k(val), keys(key), data(std::move(arg)), subs(std::move(sub)), m_script_ctx{script_ctx}, ops(CalcOps()), ss(CalcStackSize()), ws(CalcWitnessSize()), typ(CalcType()), scriptlen(CalcScriptLen()) {}
+ : fragment(nt), k(val), keys(std::move(key)), data(std::move(arg)), subs(std::move(sub)), m_script_ctx{script_ctx}, ops(CalcOps()), ss(CalcStackSize()), ws(CalcWitnessSize()), typ(CalcType()), scriptlen(CalcScriptLen()) {}
//! Compute the length of the script for this miniscript (including children).
size_t CalcScriptLen() const
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.