diff --git a/src/streams.h b/src/streams.h index d6d6d57fb93..4fc5879f67e 100644 --- a/src/streams.h +++ b/src/streams.h @@ -206,12 +206,6 @@ public: value_type* data() { return vch.data() + m_read_pos; } const value_type* data() const { return vch.data() + m_read_pos; } - inline void Compact() - { - vch.erase(vch.begin(), vch.begin() + m_read_pos); - m_read_pos = 0; - } - bool Rewind(std::optional n = std::nullopt) { // Total rewind if no size is passed @@ -243,8 +237,8 @@ public: } memcpy(dst.data(), &vch[m_read_pos], dst.size()); if (next_read_pos.value() == vch.size()) { - m_read_pos = 0; - vch.clear(); + // If fully consumed, reset to empty state. + clear(); return; } m_read_pos = next_read_pos.value(); @@ -258,8 +252,8 @@ public: throw std::ios_base::failure("DataStream::ignore(): end of data"); } if (next_read_pos.value() == vch.size()) { - m_read_pos = 0; - vch.clear(); + // If all bytes are ignored, reset to empty state. + clear(); return; } m_read_pos = next_read_pos.value();