From b7b036c210aba03c5dc1851b9de5fe9b3351dcd8 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 20 Nov 2022 16:59:08 +1100 Subject: Change BufferIterator comparison to assert same buffer Comparing iterators between buffers should never happen, and the only place we did was with default constructed BufferIterator which we replace by casting the iterator to bool. This should improve performance on iterator heavy code. --- src/buffer.hh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/buffer.hh') diff --git a/src/buffer.hh b/src/buffer.hh index ce336e96..71c5cd51 100644 --- a/src/buffer.hh +++ b/src/buffer.hh @@ -75,6 +75,8 @@ public: const char& operator[](size_t n) const noexcept; size_t operator- (const BufferIterator& iterator) const; + explicit operator bool() const { return static_cast(m_buffer); } + BufferIterator operator+ (ByteCount size) const; BufferIterator operator- (ByteCount size) const; -- cgit v1.2.3