diff options
| author | Maxime Coste <mawww@kakoune.org> | 2018-11-01 21:51:10 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2018-11-01 21:51:10 +1100 |
| commit | 6fce8050ee29c97a96ff97823698d539b7c734d0 (patch) | |
| tree | 3dbf730427b761f02336caa4d422e25c475c8188 /src/buffer.hh | |
| parent | 8a751e1b57b07ff43739e69f395ee4dfc3431ba0 (diff) | |
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.
Diffstat (limited to 'src/buffer.hh')
| -rw-r--r-- | src/buffer.hh | 5 |
1 files changed, 5 insertions, 0 deletions
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<const Buffer> m_buffer; |
