diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-06-02 15:13:56 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-06-02 15:13:56 +0100 |
| commit | d33c27acdf7ebf5c9be0ab1406ae4c7e66fb671e (patch) | |
| tree | 33b69998aa4b2429d2d1e2e024c575f1bd66c199 /src/selection.hh | |
| parent | 23a1914d7e0bff8f71608b81348632c676e3ae19 (diff) | |
Move compute_modified_ranges to selection.cc and use an optimized approach
Diffstat (limited to 'src/selection.hh')
| -rw-r--r-- | src/selection.hh | 32 |
1 files changed, 1 insertions, 31 deletions
diff --git a/src/selection.hh b/src/selection.hh index d9c2ea87..cdfca6b6 100644 --- a/src/selection.hh +++ b/src/selection.hh @@ -53,11 +53,6 @@ inline bool overlaps(const Selection& lhs, const Selection& rhs) : lhs.min() <= rhs.max(); } -static bool compare_selections(const Selection& lhs, const Selection& rhs) -{ - return lhs.min() < rhs.min(); -} - enum class InsertMode : unsigned { Insert, @@ -71,30 +66,6 @@ enum class InsertMode : unsigned OpenLineAbove }; -template<typename Iterator, typename OverlapsFunc> -Iterator merge_overlapping(Iterator begin, Iterator end, size_t& main, OverlapsFunc overlaps) -{ - kak_assert(std::is_sorted(begin, end, compare_selections)); - size_t size = end - begin; - size_t i = 0; - for (size_t j = 1; j < size; ++j) - { - if (overlaps(begin[i], begin[j])) - { - begin[i].merge_with(begin[j]); - if (i < main) - --main; - } - else - { - ++i; - if (i != j) - begin[i] = std::move(begin[j]); - } - } - return begin + i + 1; -} - struct SelectionList { SelectionList(Buffer& buffer, Selection s); @@ -164,8 +135,7 @@ private: size_t m_timestamp; }; -void update_insert(std::vector<Selection>& sels, ByteCoord begin, ByteCoord end); -void update_erase(std::vector<Selection>& sels, ByteCoord begin, ByteCoord end); +std::vector<Selection> compute_modified_ranges(Buffer& buffer, size_t timestamp); } |
