-
Notifications
You must be signed in to change notification settings - Fork 5.3k
improved BDD Unicode table representation in NonBacktracking engine #61142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,8 +12,8 @@ namespace System.Text.RegularExpressions.Symbolic | |
| /// </summary> | ||
| internal sealed class CharSetSolver : BDDAlgebra, ICharAlgebra<BDD> | ||
| { | ||
| /// <summary>BDDs for all characters for fast lookup.</summary> | ||
| private readonly BDD[] _charPredTable = new BDD[char.MaxValue + 1]; | ||
| /// <summary>BDDs for all ASCII characters for fast lookup.</summary> | ||
| private readonly BDD[] _charPredTable = new BDD[128]; | ||
| private readonly Unicode.IgnoreCaseTransformer _ignoreCase; | ||
| internal readonly BDD _nonAscii; | ||
|
|
||
|
|
@@ -40,10 +40,23 @@ public BDD CharConstraint(char c, bool ignoreCase = false, string? culture = nul | |
| else | ||
| { | ||
| //individual character BDDs are always fixed | ||
| return _charPredTable[c] ??= CreateSetFrom(c, 15); | ||
| BDD[] charPredTable = _charPredTable; | ||
| return c < charPredTable.Length ? | ||
| charPredTable[c] ??= CreateBDDFromChar(c) : | ||
| CreateBDDFromChar(c); | ||
| } | ||
| } | ||
|
|
||
| private BDD CreateBDDFromChar(ushort c) | ||
| { | ||
| BDD bdd = BDD.True; | ||
| for (int k = 0; k < 16; k++) | ||
| { | ||
| bdd = (c & (1 << k)) == 0 ? GetOrCreateBDD(k, BDD.False, bdd) : GetOrCreateBDD(k, bdd, BDD.False); | ||
|
||
| } | ||
| return bdd; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Make a CharSet from all the characters in the range from m to n. | ||
| /// Returns the empty set if n is less than m | ||
|
|
||
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.