summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-11-09 08:42:12 +0000
committerMaxime Coste <frrrwww@gmail.com>2015-11-09 08:42:12 +0000
commit12abb54a8853b50df5815387946dbae8cf7dc448 (patch)
tree3d1fd7db4f4e864a8e0ac3627985f34f96aa0e28 /src
parent6840f7ce9cae76295ecedd92114829b413fdd6bb (diff)
Slightly more performant regex capture gathering in select_all_matches
Diffstat (limited to 'src')
-rw-r--r--src/selectors.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/selectors.cc b/src/selectors.cc
index 06257ad5..524ff9e1 100644
--- a/src/selectors.cc
+++ b/src/selectors.cc
@@ -570,6 +570,7 @@ void select_all_matches(SelectionList& selections, const Regex& regex)
RegexIt re_it(buffer.iterator_at(sel.min()), sel_end, regex);
RegexIt re_end;
+ const unsigned mark_count = regex.mark_count();
for (; re_it != re_end; ++re_it)
{
auto begin = ensure_char_start(buffer, (*re_it)[0].first);
@@ -578,8 +579,10 @@ void select_all_matches(SelectionList& selections, const Regex& regex)
auto end = ensure_char_start(buffer, (*re_it)[0].second);
CaptureList captures;
+ captures.reserve(mark_count);
for (auto& match : *re_it)
- captures.emplace_back(match.first, match.second);
+ captures.push_back(buffer.string(match.first.coord(),
+ match.second.coord()));
result.push_back(
keep_direction({ begin.coord(),