From 63371da8aa9edd7f7812c8a56ad573e46df111fd Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 29 May 2020 11:59:59 +1000 Subject: Avoid to_remove vector in select helper function Remove the need to allocate anything when removing selections. --- src/selection.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/selection.cc') diff --git a/src/selection.cc b/src/selection.cc index d637e007..4c908efb 100644 --- a/src/selection.cc +++ b/src/selection.cc @@ -33,6 +33,15 @@ void SelectionList::remove(size_t index) if (index < m_main or m_main == m_selections.size()) --m_main; } + +void SelectionList::remove_from(size_t index) +{ + kak_assert(index > 0); + m_selections.erase(begin() + index, end()); + if (index <= m_main) + m_main = m_selections.size() - 1; +} + void SelectionList::set(Vector list, size_t main) { kak_assert(main < list.size()); -- cgit v1.2.3