From be0c5ddf49b30700d61515ef79d1909f0a6344f8 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 27 Feb 2013 19:03:33 +0100 Subject: [PATCH] minor performance tweaks --- src/buffer_iterator.inl.hh | 9 +++++---- src/dynamic_selection_list.cc | 14 ++++++++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/buffer_iterator.inl.hh b/src/buffer_iterator.inl.hh index 1e477561..717da898 100644 --- a/src/buffer_iterator.inl.hh +++ b/src/buffer_iterator.inl.hh @@ -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()); } diff --git a/src/dynamic_selection_list.cc b/src/dynamic_selection_list.cc index a0152341..b684ec56 100644 --- a/src/dynamic_selection_list.cc +++ b/src/dynamic_selection_list.cc @@ -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); } }