From c1db67e31a18a723f455fa0b93c09f01100fcb59 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 13 Mar 2013 14:25:22 +0100 Subject: [PATCH] Buffer: minor refactoring --- src/buffer.cc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/buffer.cc b/src/buffer.cc index ac11553f..e86df929 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -86,11 +86,6 @@ BufferCoord Buffer::clamp(const BufferCoord& line_and_column, return result; } -BufferIterator Buffer::iterator_at_line_begin(const BufferIterator& iterator) const -{ - return BufferIterator(*this, { iterator.line(), 0 }); -} - BufferIterator Buffer::iterator_at_line_begin(LineCount line) const { line = Kakoune::clamp(line, 0_line, line_count()-1); @@ -98,11 +93,9 @@ BufferIterator Buffer::iterator_at_line_begin(LineCount line) const return BufferIterator(*this, { line, 0 }); } -BufferIterator Buffer::iterator_at_line_end(const BufferIterator& iterator) const +BufferIterator Buffer::iterator_at_line_begin(const BufferIterator& iterator) const { - LineCount line = iterator.line(); - assert(line_length(line) > 0); - return ++BufferIterator(*this, { line, line_length(line) - 1 }); + return iterator_at_line_begin(iterator.line()); } BufferIterator Buffer::iterator_at_line_end(LineCount line) const @@ -112,6 +105,11 @@ BufferIterator Buffer::iterator_at_line_end(LineCount line) const return ++BufferIterator(*this, { line, line_length(line) - 1 }); } +BufferIterator Buffer::iterator_at_line_end(const BufferIterator& iterator) const +{ + return iterator_at_line_end(iterator.line()); +} + BufferIterator Buffer::begin() const { return BufferIterator(*this, { 0_line, 0 });