minor performance tweaks
This commit is contained in:
parent
cd8c36fc50
commit
be0c5ddf49
|
@ -76,7 +76,7 @@ inline void BufferIterator::on_insert(const BufferCoord& begin,
|
|||
if (m_coord < begin)
|
||||
return;
|
||||
|
||||
if (begin.line == line())
|
||||
if (begin.line == m_coord.line)
|
||||
m_coord.column = end.column + m_coord.column - begin.column;
|
||||
m_coord.line += end.line - begin.line;
|
||||
|
||||
|
@ -90,7 +90,11 @@ inline void BufferIterator::on_erase(const BufferCoord& begin,
|
|||
return;
|
||||
|
||||
if (m_coord <= end)
|
||||
{
|
||||
m_coord = begin;
|
||||
if (is_end())
|
||||
operator--();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (end.line == m_coord.line)
|
||||
|
@ -101,9 +105,6 @@ inline void BufferIterator::on_erase(const BufferCoord& begin,
|
|||
else
|
||||
m_coord.line -= end.line - begin.line;
|
||||
}
|
||||
|
||||
if (is_end())
|
||||
operator--();
|
||||
assert(is_valid());
|
||||
}
|
||||
|
||||
|
|
|
@ -63,28 +63,34 @@ DynamicSelectionList& DynamicSelectionList::operator=(SelectionList selections)
|
|||
|
||||
void DynamicSelectionList::check_invariant() const
|
||||
{
|
||||
#ifdef KAK_DEBUG
|
||||
for (auto& sel : *this)
|
||||
{
|
||||
assert(m_buffer == &sel.buffer());
|
||||
sel.check_invariant();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void DynamicSelectionList::on_insert(const BufferIterator& begin, const BufferIterator& end)
|
||||
{
|
||||
const BufferCoord begin_coord{begin.coord()};
|
||||
const BufferCoord end_coord{end.coord()};
|
||||
for (auto& sel : *this)
|
||||
{
|
||||
sel.first().on_insert(begin.coord(), end.coord());
|
||||
sel.last().on_insert(begin.coord(), end.coord());
|
||||
sel.first().on_insert(begin_coord, end_coord);
|
||||
sel.last().on_insert(begin_coord, end_coord);
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicSelectionList::on_erase(const BufferIterator& begin, const BufferIterator& end)
|
||||
{
|
||||
const BufferCoord begin_coord{begin.coord()};
|
||||
const BufferCoord end_coord{end.coord()};
|
||||
for (auto& sel : *this)
|
||||
{
|
||||
sel.first().on_erase(begin.coord(), end.coord());
|
||||
sel.last().on_erase(begin.coord(), end.coord());
|
||||
sel.first().on_erase(begin_coord, end_coord);
|
||||
sel.last().on_erase(begin_coord, end_coord);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user