summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2018-10-30 23:18:41 +1100
committerMaxime Coste <mawww@kakoune.org>2018-10-30 23:18:41 +1100
commit9fec1b3fafe4a9a3126e203ee01045ed4ae15aba (patch)
treea62a78c4d1ce81977e4948651d3f5e6a6d7032c5 /src
parent6271d0d9ff8b68f6f0d63e1c5b4ca9de991b43b5 (diff)
Buffer: Remove m_line_count field from BufferIterator
It seems unlikely this would give performance gain, as buffer lines are always accessed when we read that field, leading to all the necessary data already being in memory. Removing it reduces the size of a BufferIterator, which are already pretty hefty objects.
Diffstat (limited to 'src')
-rw-r--r--src/buffer.hh1
-rw-r--r--src/buffer.inl.hh3
2 files changed, 1 insertions, 3 deletions
diff --git a/src/buffer.hh b/src/buffer.hh
index 0cdb8209..3114e861 100644
--- a/src/buffer.hh
+++ b/src/buffer.hh
@@ -92,7 +92,6 @@ public:
private:
SafePtr<const Buffer> m_buffer;
BufferCoord m_coord;
- LineCount m_line_count;
StringView m_line;
};
diff --git a/src/buffer.inl.hh b/src/buffer.inl.hh
index 6816e818..e7538694 100644
--- a/src/buffer.inl.hh
+++ b/src/buffer.inl.hh
@@ -100,7 +100,6 @@ inline BufferCoord Buffer::end_coord() const
inline BufferIterator::BufferIterator(const Buffer& buffer, BufferCoord coord) noexcept
: m_buffer{&buffer}, m_coord{coord},
- m_line_count{buffer.line_count()},
m_line{coord.line < buffer.line_count() ? (*m_buffer)[coord.line] : StringView{}} {}
inline bool BufferIterator::operator==(const BufferIterator& iterator) const noexcept
@@ -183,7 +182,7 @@ inline BufferIterator& BufferIterator::operator++()
{
if (++m_coord.column == m_line.length())
{
- m_line = (++m_coord.line < m_line_count) ?
+ m_line = (++m_coord.line < m_buffer->line_count()) ?
(*m_buffer)[m_coord.line] : StringView{};
m_coord.column = 0;
}