Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions benchmarks/src/regex_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,8 @@ BENCHMARK_CAPTURE(bm_lorem_search, R"(\Bibe)", R"(\Bibe)")->Apply(common_args);
BENCHMARK_CAPTURE(bm_lorem_search, R"((?=....)bibe)", R"((?=....)bibe)")->Apply(common_args);
BENCHMARK_CAPTURE(bm_lorem_search, R"((?=bibe)....)", R"((?=bibe)....)")->Apply(common_args);
BENCHMARK_CAPTURE(bm_lorem_search, R"((?!lorem)bibe)", R"((?!lorem)bibe)")->Apply(common_args);
BENCHMARK_CAPTURE(bm_lorem_search, "(bibe|soda)", "(bibe|soda)")->Apply(common_args);
BENCHMARK_CAPTURE(bm_lorem_search, "(id )?bibe", "(id )?bibe")->Apply(common_args);
BENCHMARK_CAPTURE(bm_lorem_search, ".bibe", ".bibe")->Apply(common_args);

BENCHMARK_MAIN();
11 changes: 10 additions & 1 deletion stl/inc/regex
Original file line number Diff line number Diff line change
Expand Up @@ -5015,13 +5015,22 @@ _It _Matcher3<_Elem, _RxTraits, _It, _Alloc>::_Skip(
return _First;
}

case _N_dot:
{
if (_Recursion_depth >= _Max_recursion_depth) {
return _First;
}

_First = _Skip(++_First, _Last, _Nx->_Next, _Recursion_depth + 1U);
return --_First;
}

case _N_begin:
case _N_endif:
break;

case _N_end:
case _N_none:
case _N_dot:
case _N_back:
case _N_end_rep:
default:
Expand Down
16 changes: 16 additions & 0 deletions tests/std/tests/VSO_0000000_regex_use/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2507,6 +2507,21 @@ void test_gh_6181() {
}
}

void test_gh_6189() {
// GH-6189: Optimize skip heuristic for searches of patterns with initial dot wildcards
test_regex re(&g_regexTester, ".abc");
re.should_search_match("dabc", "dabc");
re.should_search_match("dabcdddd", "dabc");
re.should_search_match("ddabc", "dabc");
re.should_search_match("ddabcdddd", "dabc");
re.should_search_match("ddddddddddddddddabcdddddddddddd", "dabc");
re.should_search_match("ddddddddddddddddddddddddabc", "dabc");
re.should_search_match("ddabcddd", "dabc");
re.should_search_fail("abcddddd");
re.should_search_fail("ddddddddddd\nabcdddddddddd");
re.should_search_fail("d");
}

int main() {
test_dev10_449367_case_insensitivity_should_work();
test_dev11_462743_regex_collate_should_not_disable_regex_icase();
Expand Down Expand Up @@ -2572,6 +2587,7 @@ int main() {
test_gh_6118();
test_gh_6147();
test_gh_6181();
test_gh_6189();

return g_regexTester.result();
}