From d29fa04adc6a15c8d62ffcd4390e5fc785d92b62 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 3 Dec 2024 21:26:57 +1100 Subject: Do not store buffer pointer in BufferIterator This makes BufferIterator smaller and trivially move/copyable --- src/buffer.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/buffer.cc') diff --git a/src/buffer.cc b/src/buffer.cc index ada61ad8..f0205c54 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -570,17 +570,17 @@ void Buffer::notify_saved(FsStatus status) m_fs_status = status; } -BufferCoord Buffer::advance(BufferCoord coord, ByteCount count) const +BufferCoord Buffer::advance(ArrayView lines, BufferCoord coord, ByteCount count) { if (count > 0) { auto line = coord.line; count += coord.column; - while (count >= m_lines[line].length()) + while (count >= lines[(size_t)line]->length) { - count -= m_lines[line++].length(); - if (line == line_count()) - return end_coord(); + count -= lines[(size_t)line++]->length; + if ((size_t)line == lines.size()) + return line; } return { line, count }; } @@ -592,7 +592,7 @@ BufferCoord Buffer::advance(BufferCoord coord, ByteCount count) const { if (--line < 0) return {0, 0}; - count += m_lines[line].length(); + count += lines[(size_t)line]->length; } return { line, count }; } -- cgit v1.2.3