bench: Construct CTxOut and COutPoint in a single expression #36019

pull alexanderwiederin wants to merge 1 commits into bitcoin:master from alexanderwiederin:bench-declarative changing 2 files +3 −7
  1. alexanderwiederin commented at 8:33 AM on August 19, 2026: contributor

    Replaces field-by-field mutation of CTxOut and COutPoint in two bench files with brace initialisation, which requires the size_t conversions to be made explicit.

    Noticed while looking at #35994, where switching the proposed fix-it to {} surfaces implicit narrowing conversions like these.

    The constructed values are unchanged.

    Note: Only the sites where a conversion is involved are included in this PR; the remaining field-by-field construction in bench/ would be covered by #35994's follow-ups.

  2. DrahtBot added the label Tests on Aug 19, 2026
  3. DrahtBot commented at 8:33 AM on August 19, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/36019.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process. A summary of reviews will appear here.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. bench: Construct CTxOut and COutPoint in a single expression
    Replace separate member assignments with brace initialization. The
    narrowing conversions from size_t are now explicit rather than implicit.
    5d53932496
  5. in src/bench/blockencodings.cpp:92 in 361ee92e3e
      88 | @@ -89,8 +89,7 @@ static void BlockEncodingBench(benchmark::Bench& bench, size_t n_pool, size_t n_
      89 |          tx.vin[0].scriptSig = CScript() << sigspam;
      90 |          tx.vin[0].scriptWitness.stack.push_back({1});
      91 |          tx.vout.resize(1);
      92 | -        tx.vout[0].scriptPubKey = CScript() << OP_1 << OP_EQUAL;
      93 | -        tx.vout[0].nValue = i;
      94 | +        tx.vout[0] = CTxOut{static_cast<CAmount>(i), CScript() << OP_1 << OP_EQUAL};
    


    maflcko commented at 8:37 AM on August 19, 2026:
            tx.vout = {CTxOut{static_cast<CAmount>(i), CScript() << OP_1 << OP_EQUAL}};
    

    maybe use an init-list?


    alexanderwiederin commented at 9:00 AM on August 19, 2026:

    Done - thanks!

  6. alexanderwiederin force-pushed on Aug 19, 2026
  7. DrahtBot added the label CI failed on Aug 19, 2026
  8. DrahtBot removed the label CI failed on Aug 19, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-08-19 13:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me