From e6c635be342cccb3051930d7b83a5acd9784bf9c Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 18 Mar 2013 19:06:04 +0100 Subject: [PATCH] DynamicSelectionList: optimize updating on buffer modification Now that we know selections are sorted, we can get the set of selections needing updating in log(n) time using a binary search, for modification not changing the line count, this makes updating selections run in log(n) instead of n. --- src/dynamic_selection_list.cc | 112 ++++++++++++++++++++++------------ 1 file changed, 72 insertions(+), 40 deletions(-) diff --git a/src/dynamic_selection_list.cc b/src/dynamic_selection_list.cc index 647bf22b..bca16293 100644 --- a/src/dynamic_selection_list.cc +++ b/src/dynamic_selection_list.cc @@ -72,62 +72,94 @@ void DynamicSelectionList::check_invariant() const #endif } -static void update_insert(BufferIterator& it, - const BufferCoord& begin, const BufferCoord& end) +namespace { - BufferCoord coord = it.coord(); - if (coord < begin) - return; - if (begin.line == coord.line) - coord.column = end.column + coord.column - begin.column; - coord.line += end.line - begin.line; +template