diff options
| author | Maxime Coste <mawww@kakoune.org> | 2020-05-29 11:59:59 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2020-05-29 12:00:02 +1000 |
| commit | 63371da8aa9edd7f7812c8a56ad573e46df111fd (patch) | |
| tree | e92e603b5b4463c95d80ef9eb21d61af08b7dd25 /src/selection.cc | |
| parent | 94f33bb63862357557ef533126a41d64b12f1c53 (diff) | |
Avoid to_remove vector in select helper function
Remove the need to allocate anything when removing selections.
Diffstat (limited to 'src/selection.cc')
| -rw-r--r-- | src/selection.cc | 9 |
1 files changed, 9 insertions, 0 deletions
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<Selection> list, size_t main) { kak_assert(main < list.size()); |
