diff --git a/src/buffer.hh b/src/buffer.hh index bfdda041..d0fdffcb 100644 --- a/src/buffer.hh +++ b/src/buffer.hh @@ -59,18 +59,18 @@ public: // costly, so this is not strictly random access using iterator_category = std::bidirectional_iterator_tag; - BufferIterator() : m_buffer(nullptr) {} - BufferIterator(const Buffer& buffer, BufferCoord coord); + BufferIterator() noexcept : m_buffer(nullptr) {} + BufferIterator(const Buffer& buffer, BufferCoord coord) noexcept; - bool operator== (const BufferIterator& iterator) const; - bool operator!= (const BufferIterator& iterator) const; - bool operator< (const BufferIterator& iterator) const; - bool operator<= (const BufferIterator& iterator) const; - bool operator> (const BufferIterator& iterator) const; - bool operator>= (const BufferIterator& iterator) const; + bool operator== (const BufferIterator& iterator) const noexcept; + bool operator!= (const BufferIterator& iterator) const noexcept; + bool operator< (const BufferIterator& iterator) const noexcept; + bool operator<= (const BufferIterator& iterator) const noexcept; + bool operator> (const BufferIterator& iterator) const noexcept; + bool operator>= (const BufferIterator& iterator) const noexcept; - const char& operator* () const; - const char& operator[](size_t n) const; + const char& operator* () const noexcept; + const char& operator[](size_t n) const noexcept; size_t operator- (const BufferIterator& iterator) const; BufferIterator operator+ (ByteCount size) const; @@ -85,7 +85,7 @@ public: BufferIterator operator++ (int); BufferIterator operator-- (int); - const BufferCoord& coord() const { return m_coord; } + const BufferCoord& coord() const noexcept { return m_coord; } private: SafePtr m_buffer; diff --git a/src/buffer.inl.hh b/src/buffer.inl.hh index d94ea42c..7d987c26 100644 --- a/src/buffer.inl.hh +++ b/src/buffer.inl.hh @@ -114,55 +114,52 @@ inline BufferCoord Buffer::end_coord() const BufferCoord{0,0} : BufferCoord{ line_count() - 1, m_lines.back().length() }; } -inline BufferIterator::BufferIterator(const Buffer& buffer, BufferCoord coord) +inline BufferIterator::BufferIterator(const Buffer& buffer, BufferCoord coord) noexcept : m_buffer(&buffer), m_coord(coord), m_line((*m_buffer)[coord.line]), - m_last_line(buffer.line_count()-1) -{ - kak_assert(m_buffer and m_buffer->is_valid(m_coord)); -} + m_last_line(buffer.line_count()-1) {} -inline bool BufferIterator::operator==(const BufferIterator& iterator) const +inline bool BufferIterator::operator==(const BufferIterator& iterator) const noexcept { return m_buffer == iterator.m_buffer and m_coord == iterator.m_coord; } -inline bool BufferIterator::operator!=(const BufferIterator& iterator) const +inline bool BufferIterator::operator!=(const BufferIterator& iterator) const noexcept { return m_buffer != iterator.m_buffer or m_coord != iterator.m_coord; } -inline bool BufferIterator::operator<(const BufferIterator& iterator) const +inline bool BufferIterator::operator<(const BufferIterator& iterator) const noexcept { kak_assert(m_buffer == iterator.m_buffer); return (m_coord < iterator.m_coord); } -inline bool BufferIterator::operator<=(const BufferIterator& iterator) const +inline bool BufferIterator::operator<=(const BufferIterator& iterator) const noexcept { kak_assert(m_buffer == iterator.m_buffer); return (m_coord <= iterator.m_coord); } -inline bool BufferIterator::operator>(const BufferIterator& iterator) const +inline bool BufferIterator::operator>(const BufferIterator& iterator) const noexcept { kak_assert(m_buffer == iterator.m_buffer); return (m_coord > iterator.m_coord); } -inline bool BufferIterator::operator>=(const BufferIterator& iterator) const +inline bool BufferIterator::operator>=(const BufferIterator& iterator) const noexcept { kak_assert(m_buffer == iterator.m_buffer); return (m_coord >= iterator.m_coord); } [[gnu::always_inline]] -inline const char& BufferIterator::operator*() const +inline const char& BufferIterator::operator*() const noexcept { return m_line[m_coord.column]; } -inline const char& BufferIterator::operator[](size_t n) const +inline const char& BufferIterator::operator[](size_t n) const noexcept { return m_buffer->byte_at(m_buffer->advance(m_coord, n)); }