mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
Remove broken and unused CDataStream methods
This commit is contained in:
parent
faee5f8dc2
commit
fa1b227a72
2 changed files with 0 additions and 112 deletions
|
@ -240,76 +240,9 @@ public:
|
|||
const_reference operator[](size_type pos) const { return vch[pos + nReadPos]; }
|
||||
reference operator[](size_type pos) { return vch[pos + nReadPos]; }
|
||||
void clear() { vch.clear(); nReadPos = 0; }
|
||||
iterator insert(iterator it, const value_type x) { return vch.insert(it, x); }
|
||||
void insert(iterator it, size_type n, const value_type x) { vch.insert(it, n, x); }
|
||||
value_type* data() { return vch.data() + nReadPos; }
|
||||
const value_type* data() const { return vch.data() + nReadPos; }
|
||||
|
||||
void insert(iterator it, std::vector<value_type>::const_iterator first, std::vector<value_type>::const_iterator last)
|
||||
{
|
||||
if (last == first) return;
|
||||
assert(last - first > 0);
|
||||
if (it == vch.begin() + nReadPos && (unsigned int)(last - first) <= nReadPos)
|
||||
{
|
||||
// special case for inserting at the front when there's room
|
||||
nReadPos -= (last - first);
|
||||
memcpy(&vch[nReadPos], &first[0], last - first);
|
||||
}
|
||||
else
|
||||
vch.insert(it, first, last);
|
||||
}
|
||||
|
||||
void insert(iterator it, const value_type* first, const value_type* last)
|
||||
{
|
||||
if (last == first) return;
|
||||
assert(last - first > 0);
|
||||
if (it == vch.begin() + nReadPos && (unsigned int)(last - first) <= nReadPos)
|
||||
{
|
||||
// special case for inserting at the front when there's room
|
||||
nReadPos -= (last - first);
|
||||
memcpy(&vch[nReadPos], &first[0], last - first);
|
||||
}
|
||||
else
|
||||
vch.insert(it, first, last);
|
||||
}
|
||||
|
||||
iterator erase(iterator it)
|
||||
{
|
||||
if (it == vch.begin() + nReadPos)
|
||||
{
|
||||
// special case for erasing from the front
|
||||
if (++nReadPos >= vch.size())
|
||||
{
|
||||
// whenever we reach the end, we take the opportunity to clear the buffer
|
||||
nReadPos = 0;
|
||||
return vch.erase(vch.begin(), vch.end());
|
||||
}
|
||||
return vch.begin() + nReadPos;
|
||||
}
|
||||
else
|
||||
return vch.erase(it);
|
||||
}
|
||||
|
||||
iterator erase(iterator first, iterator last)
|
||||
{
|
||||
if (first == vch.begin() + nReadPos)
|
||||
{
|
||||
// special case for erasing from the front
|
||||
if (last == vch.end())
|
||||
{
|
||||
nReadPos = 0;
|
||||
return vch.erase(vch.begin(), vch.end());
|
||||
}
|
||||
else
|
||||
{
|
||||
nReadPos = (last - vch.begin());
|
||||
return last;
|
||||
}
|
||||
}
|
||||
else
|
||||
return vch.erase(first, last);
|
||||
}
|
||||
|
||||
inline void Compact()
|
||||
{
|
||||
vch.erase(vch.begin(), vch.begin() + nReadPos);
|
||||
|
|
|
@ -215,51 +215,6 @@ BOOST_AUTO_TEST_CASE(noncanonical)
|
|||
BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalException);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(insert_delete)
|
||||
{
|
||||
constexpr auto B2I{[](std::byte b) { return std::to_integer<uint8_t>(b); }};
|
||||
|
||||
// Test inserting/deleting bytes.
|
||||
CDataStream ss(SER_DISK, 0);
|
||||
BOOST_CHECK_EQUAL(ss.size(), 0U);
|
||||
|
||||
ss.write(MakeByteSpan("\x00\x01\x02\xff").first(4));
|
||||
BOOST_CHECK_EQUAL(ss.size(), 4U);
|
||||
|
||||
uint8_t c{11};
|
||||
|
||||
// Inserting at beginning/end/middle:
|
||||
ss.insert(ss.begin(), std::byte{c});
|
||||
BOOST_CHECK_EQUAL(ss.size(), 5U);
|
||||
BOOST_CHECK_EQUAL(B2I(ss[0]), c);
|
||||
BOOST_CHECK_EQUAL(B2I(ss[1]), 0);
|
||||
|
||||
ss.insert(ss.end(), std::byte{c});
|
||||
BOOST_CHECK_EQUAL(ss.size(), 6U);
|
||||
BOOST_CHECK_EQUAL(B2I(ss[4]), 0xff);
|
||||
BOOST_CHECK_EQUAL(B2I(ss[5]), c);
|
||||
|
||||
ss.insert(ss.begin() + 2, std::byte{c});
|
||||
BOOST_CHECK_EQUAL(ss.size(), 7U);
|
||||
BOOST_CHECK_EQUAL(B2I(ss[2]), c);
|
||||
|
||||
// Delete at beginning/end/middle
|
||||
ss.erase(ss.begin());
|
||||
BOOST_CHECK_EQUAL(ss.size(), 6U);
|
||||
BOOST_CHECK_EQUAL(B2I(ss[0]), 0);
|
||||
|
||||
ss.erase(ss.begin()+ss.size()-1);
|
||||
BOOST_CHECK_EQUAL(ss.size(), 5U);
|
||||
BOOST_CHECK_EQUAL(B2I(ss[4]), 0xff);
|
||||
|
||||
ss.erase(ss.begin()+1);
|
||||
BOOST_CHECK_EQUAL(ss.size(), 4U);
|
||||
BOOST_CHECK_EQUAL(B2I(ss[0]), 0);
|
||||
BOOST_CHECK_EQUAL(B2I(ss[1]), 1);
|
||||
BOOST_CHECK_EQUAL(B2I(ss[2]), 2);
|
||||
BOOST_CHECK_EQUAL(B2I(ss[3]), 0xff);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(class_methods)
|
||||
{
|
||||
int intval(100);
|
||||
|
|
Loading…
Add table
Reference in a new issue