aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2022-02-03 20:10:11 +0100
committerMarcoFalke <falke.marco@gmail.com>2022-02-03 20:16:50 +0100
commitfa1b227a727a5056c6fbc7e4f33c19aeb5207718 (patch)
tree25efb59513de5da0ca4cda777a3f82cea3d144ad /src
parentfaee5f8dc23cd2fcfb6ad62a1d46ad3020ef0c5c (diff)
downloadbitcoin-fa1b227a727a5056c6fbc7e4f33c19aeb5207718.tar.xz
Remove broken and unused CDataStream methods
Diffstat (limited to 'src')
-rw-r--r--src/streams.h67
-rw-r--r--src/test/serialize_tests.cpp45
2 files changed, 0 insertions, 112 deletions
diff --git a/src/streams.h b/src/streams.h
index 2f26be6dd8..cf8b4eb96f 100644
--- a/src/streams.h
+++ b/src/streams.h
@@ -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);
diff --git a/src/test/serialize_tests.cpp b/src/test/serialize_tests.cpp
index 8b8133b689..2441847f99 100644
--- a/src/test/serialize_tests.cpp
+++ b/src/test/serialize_tests.cpp
@@ -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);