diff options
| author | Maxime Coste <mawww@kakoune.org> | 2024-12-03 21:26:57 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2024-12-03 21:30:48 +1100 |
| commit | d29fa04adc6a15c8d62ffcd4390e5fc785d92b62 (patch) | |
| tree | 9fd25a12f2cb5b18332b8f7767e76cb531782882 /src/buffer.cc | |
| parent | 6f29950e913a05bfad8baf1f515e36cf15dd2bb2 (diff) | |
Do not store buffer pointer in BufferIterator
This makes BufferIterator smaller and trivially move/copyable
Diffstat (limited to 'src/buffer.cc')
| -rw-r--r-- | src/buffer.cc | 12 |
1 files changed, 6 insertions, 6 deletions
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<const StringDataPtr> 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 }; } |
