mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-25 12:36:11 +03:00
Much faster implementation of SelectionList::merge_overlapping
This commit is contained in:
parent
86eaa64982
commit
ab508ea3da
@ -120,19 +120,25 @@ struct SelectionList : std::vector<Selection>
|
||||
void merge_overlapping(OverlapsFunc overlaps)
|
||||
{
|
||||
kak_assert(std::is_sorted(begin(), end(), compare_selections));
|
||||
for (size_t i = 0; i+1 < size() and size() > 1;)
|
||||
size_t i = 0;
|
||||
for (size_t j = 1; j < size(); ++j)
|
||||
{
|
||||
if (overlaps((*this)[i], (*this)[i+1]))
|
||||
if (overlaps((*this)[i], (*this)[j]))
|
||||
{
|
||||
(*this)[i].merge_with((*this)[i+1]);
|
||||
erase(begin() + i + 1);
|
||||
if (i + 1 <= m_main)
|
||||
(*this)[i].merge_with((*this)[j]);
|
||||
if (i < m_main)
|
||||
--m_main;
|
||||
}
|
||||
else
|
||||
{
|
||||
++i;
|
||||
if (i != j)
|
||||
(*this)[i] = std::move((*this)[j]);
|
||||
}
|
||||
}
|
||||
erase(begin() + i + 1, end());
|
||||
kak_assert(std::is_sorted(begin(), end(), compare_selections));
|
||||
}
|
||||
|
||||
void sort_and_merge_overlapping()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user