diff options
| author | Maxime Coste <mawww@kakoune.org> | 2018-12-20 23:07:50 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2019-01-20 22:59:28 +1100 |
| commit | 8c2603ab3ca58e24ca227bd42e0550adb74fa95f (patch) | |
| tree | 11c870a9a08bae944a1495965f87e25336013ef5 /src/selectors.cc | |
| parent | 30897fd820df7bb572b7599abeb84715128e4117 (diff) | |
Support re-using the same ThreadedRegexVM for multiple iterations
This should reduce the number of allocations as the memory allocated
for the thread stack and the saves can be re-used between runs instead
of being cleared every time.
Diffstat (limited to 'src/selectors.cc')
| -rw-r--r-- | src/selectors.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/selectors.cc b/src/selectors.cc index fc661c08..06c64546 100644 --- a/src/selectors.cc +++ b/src/selectors.cc @@ -931,12 +931,13 @@ void select_all_matches(SelectionList& selections, const Regex& regex, int captu Vector<Selection> result; auto& buffer = selections.buffer(); + ThreadedRegexVM<BufferIterator, MatchDirection::Forward> vm{*regex.impl()}; for (auto& sel : selections) { auto sel_beg = buffer.iterator_at(sel.min()); auto sel_end = utf8::next(buffer.iterator_at(sel.max()), buffer.end()); - for (auto&& match : RegexIterator{sel_beg, sel_end, regex, match_flags(buffer, sel_beg, sel_end)}) + for (auto&& match : RegexIterator{sel_beg, sel_end, vm, match_flags(buffer, sel_beg, sel_end)}) { auto begin = match[capture].first; if (begin == sel_end) @@ -972,12 +973,13 @@ void split_selections(SelectionList& selections, const Regex& regex, int capture auto& buffer = selections.buffer(); auto buf_end = buffer.end(); auto buf_begin = buffer.begin(); + ThreadedRegexVM<BufferIterator, MatchDirection::Forward> vm{*regex.impl()}; for (auto& sel : selections) { auto begin = buffer.iterator_at(sel.min()); auto sel_end = utf8::next(buffer.iterator_at(sel.max()), buffer.end()); - for (auto&& match : RegexIterator{begin, sel_end, regex, match_flags(buffer, begin, sel_end)}) + for (auto&& match : RegexIterator{begin, sel_end, vm, match_flags(buffer, begin, sel_end)}) { BufferIterator end = match[capture].first; if (end == buf_end) |
