diff options
| author | Maxime Coste <mawww@kakoune.org> | 2024-11-28 08:20:29 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2024-11-28 08:20:29 +1100 |
| commit | 7ae1fd683defbd11b54ba7046df69be692ce4de5 (patch) | |
| tree | fc8d44ec90c75c1ab6faaab620211280edf666ac /src | |
| parent | c3b01a3c9caf030a8c6f6dca56688aca57a9248e (diff) | |
Raise the regex idle function call period to every 16M codepoint
Diffstat (limited to 'src')
| -rw-r--r-- | src/regex_impl.hh | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/regex_impl.hh b/src/regex_impl.hh index f62c31da..56b1d867 100644 --- a/src/regex_impl.hh +++ b/src/regex_impl.hh @@ -490,12 +490,15 @@ private: constexpr bool search = mode & RegexMode::Search; constexpr bool any_match = mode & RegexMode::AnyMatch; uint16_t current_step = -1; + constexpr size_t idle_frequency = 255; // Run idle loop every 255 * 65536 == 16M codepoints + size_t wrap_count = 0; m_found_match = false; while (true) // Iterate on all codepoints and once at the end { if (++current_step == 0) { - idle_func(); + if ((++wrap_count % idle_frequency) == 0) + idle_func(); // We wrapped, avoid potential collision on inst.last_step by resetting them for (auto& inst : forward ? insts.subrange(0, m_program.first_backward_inst) |
