From 6fce8050ee29c97a96ff97823698d539b7c734d0 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 1 Nov 2018 21:51:10 +1100 Subject: Use BufferCoord sentinel type for regex matching on BufferIterators BufferIterators are large-ish, and need to check the buffer pointer on comparison. Checking against a coord is just a 64 bit comparison. --- src/buffer.hh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/buffer.hh') diff --git a/src/buffer.hh b/src/buffer.hh index 3114e861..4d48987f 100644 --- a/src/buffer.hh +++ b/src/buffer.hh @@ -71,6 +71,9 @@ public: bool operator> (const BufferIterator& iterator) const noexcept; bool operator>= (const BufferIterator& iterator) const noexcept; + bool operator== (const BufferCoord& coord) const noexcept; + bool operator!= (const BufferCoord& coord) const noexcept; + const char& operator* () const noexcept; const char& operator[](size_t n) const noexcept; size_t operator- (const BufferIterator& iterator) const; @@ -88,6 +91,8 @@ public: BufferIterator operator-- (int); const BufferCoord& coord() const noexcept { return m_coord; } + explicit operator BufferCoord() const noexcept { return m_coord; } + using Sentinel = BufferCoord; private: SafePtr m_buffer; -- cgit v1.2.3