Skip to content

Commit fa1b227

Browse files
author
MarcoFalke
committed
Remove broken and unused CDataStream methods
1 parent faee5f8 commit fa1b227

File tree

2 files changed

+0
-112
lines changed

2 files changed

+0
-112
lines changed

src/streams.h

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -240,76 +240,9 @@ class CDataStream
240240
const_reference operator[](size_type pos) const { return vch[pos + nReadPos]; }
241241
reference operator[](size_type pos) { return vch[pos + nReadPos]; }
242242
void clear() { vch.clear(); nReadPos = 0; }
243-
iterator insert(iterator it, const value_type x) { return vch.insert(it, x); }
244-
void insert(iterator it, size_type n, const value_type x) { vch.insert(it, n, x); }
245243
value_type* data() { return vch.data() + nReadPos; }
246244
const value_type* data() const { return vch.data() + nReadPos; }
247245

248-
void insert(iterator it, std::vector<value_type>::const_iterator first, std::vector<value_type>::const_iterator last)
249-
{
250-
if (last == first) return;
251-
assert(last - first > 0);
252-
if (it == vch.begin() + nReadPos && (unsigned int)(last - first) <= nReadPos)
253-
{
254-
// special case for inserting at the front when there's room
255-
nReadPos -= (last - first);
256-
memcpy(&vch[nReadPos], &first[0], last - first);
257-
}
258-
else
259-
vch.insert(it, first, last);
260-
}
261-
262-
void insert(iterator it, const value_type* first, const value_type* last)
263-
{
264-
if (last == first) return;
265-
assert(last - first > 0);
266-
if (it == vch.begin() + nReadPos && (unsigned int)(last - first) <= nReadPos)
267-
{
268-
// special case for inserting at the front when there's room
269-
nReadPos -= (last - first);
270-
memcpy(&vch[nReadPos], &first[0], last - first);
271-
}
272-
else
273-
vch.insert(it, first, last);
274-
}
275-
276-
iterator erase(iterator it)
277-
{
278-
if (it == vch.begin() + nReadPos)
279-
{
280-
// special case for erasing from the front
281-
if (++nReadPos >= vch.size())
282-
{
283-
// whenever we reach the end, we take the opportunity to clear the buffer
284-
nReadPos = 0;
285-
return vch.erase(vch.begin(), vch.end());
286-
}
287-
return vch.begin() + nReadPos;
288-
}
289-
else
290-
return vch.erase(it);
291-
}
292-
293-
iterator erase(iterator first, iterator last)
294-
{
295-
if (first == vch.begin() + nReadPos)
296-
{
297-
// special case for erasing from the front
298-
if (last == vch.end())
299-
{
300-
nReadPos = 0;
301-
return vch.erase(vch.begin(), vch.end());
302-
}
303-
else
304-
{
305-
nReadPos = (last - vch.begin());
306-
return last;
307-
}
308-
}
309-
else
310-
return vch.erase(first, last);
311-
}
312-
313246
inline void Compact()
314247
{
315248
vch.erase(vch.begin(), vch.begin() + nReadPos);

src/test/serialize_tests.cpp

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -215,51 +215,6 @@ BOOST_AUTO_TEST_CASE(noncanonical)
215215
BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalException);
216216
}
217217

218-
BOOST_AUTO_TEST_CASE(insert_delete)
219-
{
220-
constexpr auto B2I{[](std::byte b) { return std::to_integer<uint8_t>(b); }};
221-
222-
// Test inserting/deleting bytes.
223-
CDataStream ss(SER_DISK, 0);
224-
BOOST_CHECK_EQUAL(ss.size(), 0U);
225-
226-
ss.write(MakeByteSpan("\x00\x01\x02\xff").first(4));
227-
BOOST_CHECK_EQUAL(ss.size(), 4U);
228-
229-
uint8_t c{11};
230-
231-
// Inserting at beginning/end/middle:
232-
ss.insert(ss.begin(), std::byte{c});
233-
BOOST_CHECK_EQUAL(ss.size(), 5U);
234-
BOOST_CHECK_EQUAL(B2I(ss[0]), c);
235-
BOOST_CHECK_EQUAL(B2I(ss[1]), 0);
236-
237-
ss.insert(ss.end(), std::byte{c});
238-
BOOST_CHECK_EQUAL(ss.size(), 6U);
239-
BOOST_CHECK_EQUAL(B2I(ss[4]), 0xff);
240-
BOOST_CHECK_EQUAL(B2I(ss[5]), c);
241-
242-
ss.insert(ss.begin() + 2, std::byte{c});
243-
BOOST_CHECK_EQUAL(ss.size(), 7U);
244-
BOOST_CHECK_EQUAL(B2I(ss[2]), c);
245-
246-
// Delete at beginning/end/middle
247-
ss.erase(ss.begin());
248-
BOOST_CHECK_EQUAL(ss.size(), 6U);
249-
BOOST_CHECK_EQUAL(B2I(ss[0]), 0);
250-
251-
ss.erase(ss.begin()+ss.size()-1);
252-
BOOST_CHECK_EQUAL(ss.size(), 5U);
253-
BOOST_CHECK_EQUAL(B2I(ss[4]), 0xff);
254-
255-
ss.erase(ss.begin()+1);
256-
BOOST_CHECK_EQUAL(ss.size(), 4U);
257-
BOOST_CHECK_EQUAL(B2I(ss[0]), 0);
258-
BOOST_CHECK_EQUAL(B2I(ss[1]), 1);
259-
BOOST_CHECK_EQUAL(B2I(ss[2]), 2);
260-
BOOST_CHECK_EQUAL(B2I(ss[3]), 0xff);
261-
}
262-
263218
BOOST_AUTO_TEST_CASE(class_methods)
264219
{
265220
int intval(100);

0 commit comments

Comments
 (0)