summaryrefslogtreecommitdiff
path: root/src/buffer.hh
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2024-11-30 12:27:11 +1100
committerMaxime Coste <mawww@kakoune.org>2024-11-30 23:29:34 +1100
commit8769b94eb25cd7402db6caa4f0d4b417f6365703 (patch)
tree06a4b5563c20e157292e31e2c6fe41f60c778a14 /src/buffer.hh
parent7ae1fd683defbd11b54ba7046df69be692ce4de5 (diff)
Cache buffer lines ArrayView in BufferIterator
The extra indirection of going through the buffer can be costly as the compiler does not know the buffer is not supposed to be mutated during iteration, so it has to actually reload the values which adds memory accesses in the Buffer instance which can be costly in say regex searches where memory access tends to dominate performance. Storing this in the BufferIterator lets the compiler put this info in registers and not reload it.
Diffstat (limited to 'src/buffer.hh')
-rw-r--r--src/buffer.hh2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/buffer.hh b/src/buffer.hh
index ec2b9620..fd748213 100644
--- a/src/buffer.hh
+++ b/src/buffer.hh
@@ -95,6 +95,7 @@ public:
private:
SafePtr<const Buffer> m_buffer;
+ ArrayView<const StringDataPtr> m_lines;
BufferCoord m_coord;
StringView m_line;
};
@@ -122,6 +123,7 @@ public:
ReadOnly = 1 << 6,
};
friend constexpr bool with_bit_ops(Meta::Type<Flags>) { return true; }
+ friend class BufferIterator;
enum class HistoryId : size_t { First = 0, Invalid = (size_t)-1 };