Avoid an implicit clone of the Orchard bundle in ContextualCheckTransaction.

C++ `auto`, as opposed to `auto&`, does not infer reference types (except when it does:
https://blog.petrzemek.net/2017/12/08/when-auto-seemingly-deduces-a-reference-in-cpp/
but that doesn't apply here). The inferred type of `orchard_bundle` was therefore
`const OrchardBundle`. This made the assignment a call to `OrchardBundle::operator=`
which calls `orchard_bundle_clone`. A reference assignment is sufficient, because `tx`
is in scope throughout `ContextualCheckTransaction`.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2022-09-18 17:12:55 +01:00
parent 1ef254ca80
commit 01e4c74739
1 changed files with 1 additions and 1 deletions

View File

@ -861,7 +861,7 @@ bool ContextualCheckTransaction(
assert(!nu5Active || canopyActive); // NU5 cannot be active unless Canopy is
assert(!futureActive || nu5Active); // ZFUTURE must include consensus rules for all supported network upgrades.
auto const orchard_bundle = tx.GetOrchardBundle();
auto& orchard_bundle = tx.GetOrchardBundle();
// Rules that apply only to Sprout
if (beforeOverwinter) {