diff options
author | Christian Duerr <contact@christianduerr.com> | 2023-09-17 11:04:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-17 13:04:05 +0400 |
commit | e35e5ad14fce8456afdd89f2b392b9924bb27471 (patch) | |
tree | b4ba4f415457eecf618fc25fd6ce8a4a295b2bf3 /alacritty/src/display/content.rs | |
parent | 77aa9f42bac4377efe26512d71098d21b9b547fd (diff) | |
download | r-alacritty-e35e5ad14fce8456afdd89f2b392b9924bb27471.tar.gz r-alacritty-e35e5ad14fce8456afdd89f2b392b9924bb27471.tar.bz2 r-alacritty-e35e5ad14fce8456afdd89f2b392b9924bb27471.zip |
Fix regex memory usage
This fixes an issue where regexes with a large number of possible states
would consume excessive memory, since the entire DFA was compiled ahead
of time.
To solve this, the DFA is now built at runtime using `regex-automata`'s
hybrid DFA.
There are however still some checks performed ahead of time, causing
errors with obscenely large regexes (`[0-9A-Za-z]{999999999}`), which
shouldn't cause any issues.
A regex which is large, but not large enough to fail the NFA
construction (like `[0-9A-Za-z]{999999}`) will cause a long search of
the entire grid, but will complete and show the match.
Closes #7097.
Diffstat (limited to 'alacritty/src/display/content.rs')
-rw-r--r-- | alacritty/src/display/content.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/alacritty/src/display/content.rs b/alacritty/src/display/content.rs index 039808eb..ec0f4b6a 100644 --- a/alacritty/src/display/content.rs +++ b/alacritty/src/display/content.rs @@ -41,7 +41,7 @@ impl<'a> RenderableContent<'a> { config: &'a UiConfig, display: &'a mut Display, term: &'a Term<T>, - search_state: &'a SearchState, + search_state: &'a mut SearchState, ) -> Self { let search = search_state.dfas().map(|dfas| HintMatches::visible_regex_matches(term, dfas)); let focused_match = search_state.focused_match(); @@ -486,7 +486,7 @@ impl<'a> HintMatches<'a> { } /// Create from regex matches on term visable part. - fn visible_regex_matches<T>(term: &Term<T>, dfas: &RegexSearch) -> Self { + fn visible_regex_matches<T>(term: &Term<T>, dfas: &mut RegexSearch) -> Self { let matches = hint::visible_regex_match_iter(term, dfas).collect::<Vec<_>>(); Self::new(matches) } |