summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2023-08-27 07:01:50 +1000
committerMaxime Coste <mawww@kakoune.org>2023-08-27 07:01:50 +1000
commit6f9f32b4bb7603c308a3e245fef10ad48bf20719 (patch)
treee83145495cfa18ab15c8ba11feaea6224e4239dc
parent9c0c6b8fd5a7ea8b819798add9f0605da749062b (diff)
Small code cleanup in winow.cc/hh
-rw-r--r--src/window.cc31
-rw-r--r--src/window.hh2
2 files changed, 10 insertions, 23 deletions
diff --git a/src/window.cc b/src/window.cc
index 2a0469cf..093a96ed 100644
--- a/src/window.cc
+++ b/src/window.cc
@@ -85,37 +85,24 @@ static uint32_t compute_faces_hash(const FaceRegistry& faces)
Window::Setup Window::build_setup(const Context& context) const
{
- Vector<BufferRange, MemoryDomain::Display> selections;
- for (auto& sel : context.selections())
- selections.push_back({sel.cursor(), sel.anchor()});
-
- return { m_position, m_dimensions,
- context.buffer().timestamp(),
- compute_faces_hash(context.faces()),
- context.selections().main_index(),
- std::move(selections) };
+ return {m_position, m_dimensions,
+ context.buffer().timestamp(),
+ compute_faces_hash(context.faces()),
+ context.selections().main_index(),
+ context.selections() | gather<Vector<BasicSelection, MemoryDomain::Display>>()};
}
bool Window::needs_redraw(const Context& context) const
{
auto& selections = context.selections();
-
- if (m_position != m_last_setup.position or
+ return m_position != m_last_setup.position or
m_dimensions != m_last_setup.dimensions or
context.buffer().timestamp() != m_last_setup.timestamp or
selections.main_index() != m_last_setup.main_selection or
selections.size() != m_last_setup.selections.size() or
- compute_faces_hash(context.faces()) != m_last_setup.faces_hash)
- return true;
-
- for (int i = 0; i < selections.size(); ++i)
- {
- if (selections[i].cursor() != m_last_setup.selections[i].begin or
- selections[i].anchor() != m_last_setup.selections[i].end)
- return true;
- }
-
- return false;
+ compute_faces_hash(context.faces()) != m_last_setup.faces_hash or
+ not std::equal(selections.begin(), selections.end(),
+ m_last_setup.selections.begin(), m_last_setup.selections.end());
}
const DisplayBuffer& Window::update_display_buffer(const Context& context)
diff --git a/src/window.hh b/src/window.hh
index dd7a325b..e6f27369 100644
--- a/src/window.hh
+++ b/src/window.hh
@@ -77,7 +77,7 @@ private:
size_t timestamp;
size_t faces_hash;
size_t main_selection;
- Vector<BufferRange, MemoryDomain::Display> selections;
+ Vector<BasicSelection, MemoryDomain::Display> selections;
};
Setup build_setup(const Context& context) const;
Setup m_last_setup;