summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2013-02-27 19:03:33 +0100
committerMaxime Coste <frrrwww@gmail.com>2013-02-27 19:03:33 +0100
commitbe0c5ddf49b30700d61515ef79d1909f0a6344f8 (patch)
tree0446874f9b36922a7534822581617dcade8a26f0 /src
parentcd8c36fc500dc0df5fb4232a8b1b94ab89495737 (diff)
minor performance tweaks
Diffstat (limited to 'src')
-rw-r--r--src/buffer_iterator.inl.hh9
-rw-r--r--src/dynamic_selection_list.cc14
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);
}
}