Enhanced efficiency and readability of CCoinsViewCache::FetchCoin
by replacing separate find()
and emplace()
calls with a single try_emplace()
, reducing map lookups and potential insertions.
AssembleBlock
shows FetchCoin
as one of its bottlenecks:
These changes result in a modest performance improvement:
./src/bench/bench_bitcoin –filter=‘AssembleBlock’ –min-time=10000
before:
ns/op | op/s | err% | total | benchmark |
---|---|---|---|---|
156,160.70 | 6,403.66 | 0.6% | 10.91 | AssembleBlock |
after:
ns/op | op/s | err% | total | benchmark |
---|---|---|---|---|
152,971.97 | 6,537.15 | 0.2% | 10.95 | AssembleBlock |
Further benchmarks: #30326 (comment)