diff options
author | laanwj <126646+laanwj@users.noreply.github.com> | 2022-02-09 15:17:21 +0100 |
---|---|---|
committer | laanwj <126646+laanwj@users.noreply.github.com> | 2022-02-09 16:04:43 +0100 |
commit | 5e8e0b3d7f6055e326bda61e60712b530e8920f0 (patch) | |
tree | 47e37bdfacdef0689cf095aa12098251146b35b0 /src/streams.h | |
parent | 6ac637f97f0ccdf0c6ab8565f68d37aeffe62090 (diff) | |
parent | fa1b227a727a5056c6fbc7e4f33c19aeb5207718 (diff) | |
download | bitcoin-5e8e0b3d7f6055e326bda61e60712b530e8920f0.tar.xz |
Merge bitcoin/bitcoin#24253: Remove broken and unused CDataStream methods
fa1b227a727a5056c6fbc7e4f33c19aeb5207718 Remove broken and unused CDataStream methods (MarcoFalke)
faee5f8dc23cd2fcfb6ad62a1d46ad3020ef0c5c test: Create fresh CDataStream each time (MarcoFalke)
fa71114926490e84c9222d315a95684d250e8e34 test: Inline expected_xor (MarcoFalke)
Pull request description:
The `insert` and `erase` methods have many issues:
* They are unused
* They are confusing and hard to read, as they implement "special cases" for optimization, that isn't needed
* They are broken (See https://github.com/bitcoin/bitcoin/pull/24231)
* Fixing them leads to mingw compile errors (See https://github.com/bitcoin/bitcoin/pull/24231#issuecomment-1029286985)
Fix all issues by removing them
ACKs for top commit:
laanwj:
Code review ACK fa1b227a727a5056c6fbc7e4f33c19aeb5207718
Tree-SHA512: 9d9e5d42e6ffc5ae82bdb67cfb5b50b45977ae674acee6ff99092560aebf2fc7e4584ded614e190db0663226fa198e34350517cd7ee57d518de22e9568bc349a
Diffstat (limited to 'src/streams.h')
-rw-r--r-- | src/streams.h | 67 |
1 files changed, 0 insertions, 67 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); |