diff options
| author | Maxime Coste <mawww@kakoune.org> | 2023-08-27 07:01:50 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2023-08-27 07:01:50 +1000 |
| commit | 6f9f32b4bb7603c308a3e245fef10ad48bf20719 (patch) | |
| tree | e83145495cfa18ab15c8ba11feaea6224e4239dc /src/window.cc | |
| parent | 9c0c6b8fd5a7ea8b819798add9f0605da749062b (diff) | |
Small code cleanup in winow.cc/hh
Diffstat (limited to 'src/window.cc')
| -rw-r--r-- | src/window.cc | 31 |
1 files changed, 9 insertions, 22 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) |
