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.
This commit is contained in:
parent
6271d0d9ff
commit
9fec1b3faf
|
@ -92,7 +92,6 @@ public:
|
||||||
private:
|
private:
|
||||||
SafePtr<const Buffer> m_buffer;
|
SafePtr<const Buffer> m_buffer;
|
||||||
BufferCoord m_coord;
|
BufferCoord m_coord;
|
||||||
LineCount m_line_count;
|
|
||||||
StringView m_line;
|
StringView m_line;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,6 @@ inline BufferCoord Buffer::end_coord() const
|
||||||
|
|
||||||
inline BufferIterator::BufferIterator(const Buffer& buffer, BufferCoord coord) noexcept
|
inline BufferIterator::BufferIterator(const Buffer& buffer, BufferCoord coord) noexcept
|
||||||
: m_buffer{&buffer}, m_coord{coord},
|
: m_buffer{&buffer}, m_coord{coord},
|
||||||
m_line_count{buffer.line_count()},
|
|
||||||
m_line{coord.line < buffer.line_count() ? (*m_buffer)[coord.line] : StringView{}} {}
|
m_line{coord.line < buffer.line_count() ? (*m_buffer)[coord.line] : StringView{}} {}
|
||||||
|
|
||||||
inline bool BufferIterator::operator==(const BufferIterator& iterator) const noexcept
|
inline bool BufferIterator::operator==(const BufferIterator& iterator) const noexcept
|
||||||
|
@ -183,7 +182,7 @@ inline BufferIterator& BufferIterator::operator++()
|
||||||
{
|
{
|
||||||
if (++m_coord.column == m_line.length())
|
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_buffer)[m_coord.line] : StringView{};
|
||||||
m_coord.column = 0;
|
m_coord.column = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user