This builds off #18468 since it simplifies this PR a bunch. Review that first.
We can avoid many unnecessary std::vector
allocations by changing
CBloomFilter
to take Span
s 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
CDataStream
s and uint256
s are already std::vectors
internally. We just
need a way to point to the right data within those types. Span
gives
us this ability.
This is a part of the Zero Allocations Project #18849 (ZAP3). This code came up as a place where many allocations occur. Mainly due to allocations of CService::GetKey
which is passed to these functions, but this PR is needed before we get to that.