HomePhabricator

bloom: use Span instead of std::vector for `insert` and `contains`

Description

bloom: use Span instead of std::vector for insert and contains

Summary:

We can avoid many unnecessary std::vector allocations by changing
CBloomFilter to take Spans instead of std::vector's for the insert
and contains operations.

CBloomFilter currently converts types such as CDataStream and uint256
to std::vector on insert and contains. This is unnecessary because
CDataStreams and uint256 are already std::vectors internally. We just
need a way to point to the right data within those types. Span gives
us this ability.

Signed-off-by: William Casarin <jb55@jb55.com>

https://github.com/bitcoin/bitcoin/pull/23115/commits/2ba4ddf31d27bebc144b3729479967b40bbe0b6a

refactor: Remove unused MakeUCharSpan

https://github.com/bitcoin/bitcoin/pull/23137/commits/fac303c504ab19b863fddc7a0093068fee9d4ef3

This is a partial backport of core#23115 and core#23137

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D15901

Details

Provenance
William Casarin <jb55@jb55.com>Authored on May 2 2020, 03:03
PiRKCommitted on Apr 5 2024, 12:40
PiRKPushed on Apr 5 2024, 12:40
Reviewer
Restricted Project
Differential Revision
D15901: bloom: use Span instead of std::vector for `insert` and `contains`
Parents
rABC23256e71662b: Improve release note for 0.29.1
Branches
Unknown
Tags
Unknown