mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-30 18:35:54 +02:00
scripted-diff: Use std::span over Span
-BEGIN VERIFY SCRIPT-
ren() { sed -i "s!\<$1\>!$2!g" $( git grep -l "$1" -- "./src" ":(exclude)src/span.h" ":(exclude)src/leveldb/db/log_test.cc" ) ; }
ren Span std::span
ren AsBytes std::as_bytes
ren AsWritableBytes std::as_writable_bytes
sed -i 's!SpanPopBack(Span!SpanPopBack(std::span!g' ./src/span.h
-END VERIFY SCRIPT-
This commit is contained in:
@@ -40,13 +40,13 @@ CBloomFilter::CBloomFilter(const unsigned int nElements, const double nFPRate, c
|
||||
{
|
||||
}
|
||||
|
||||
inline unsigned int CBloomFilter::Hash(unsigned int nHashNum, Span<const unsigned char> vDataToHash) const
|
||||
inline unsigned int CBloomFilter::Hash(unsigned int nHashNum, std::span<const unsigned char> vDataToHash) const
|
||||
{
|
||||
// 0xFBA4C795 chosen as it guarantees a reasonable bit difference between nHashNum values.
|
||||
return MurmurHash3(nHashNum * 0xFBA4C795 + nTweak, vDataToHash) % (vData.size() * 8);
|
||||
}
|
||||
|
||||
void CBloomFilter::insert(Span<const unsigned char> vKey)
|
||||
void CBloomFilter::insert(std::span<const unsigned char> vKey)
|
||||
{
|
||||
if (vData.empty()) // Avoid divide-by-zero (CVE-2013-5700)
|
||||
return;
|
||||
@@ -65,7 +65,7 @@ void CBloomFilter::insert(const COutPoint& outpoint)
|
||||
insert(MakeUCharSpan(stream));
|
||||
}
|
||||
|
||||
bool CBloomFilter::contains(Span<const unsigned char> vKey) const
|
||||
bool CBloomFilter::contains(std::span<const unsigned char> vKey) const
|
||||
{
|
||||
if (vData.empty()) // Avoid divide-by-zero (CVE-2013-5700)
|
||||
return true;
|
||||
@@ -187,12 +187,12 @@ CRollingBloomFilter::CRollingBloomFilter(const unsigned int nElements, const dou
|
||||
}
|
||||
|
||||
/* Similar to CBloomFilter::Hash */
|
||||
static inline uint32_t RollingBloomHash(unsigned int nHashNum, uint32_t nTweak, Span<const unsigned char> vDataToHash)
|
||||
static inline uint32_t RollingBloomHash(unsigned int nHashNum, uint32_t nTweak, std::span<const unsigned char> vDataToHash)
|
||||
{
|
||||
return MurmurHash3(nHashNum * 0xFBA4C795 + nTweak, vDataToHash);
|
||||
}
|
||||
|
||||
void CRollingBloomFilter::insert(Span<const unsigned char> vKey)
|
||||
void CRollingBloomFilter::insert(std::span<const unsigned char> vKey)
|
||||
{
|
||||
if (nEntriesThisGeneration == nEntriesPerGeneration) {
|
||||
nEntriesThisGeneration = 0;
|
||||
@@ -223,7 +223,7 @@ void CRollingBloomFilter::insert(Span<const unsigned char> vKey)
|
||||
}
|
||||
}
|
||||
|
||||
bool CRollingBloomFilter::contains(Span<const unsigned char> vKey) const
|
||||
bool CRollingBloomFilter::contains(std::span<const unsigned char> vKey) const
|
||||
{
|
||||
for (int n = 0; n < nHashFuncs; n++) {
|
||||
uint32_t h = RollingBloomHash(n, nTweak, vKey);
|
||||
|
||||
Reference in New Issue
Block a user