-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Coalesce identical constant WordCategories #84047
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
Conversation
There are four places the same mask is computed in this project, can't eliminate the one in RegexGenerator.Emitter or its matching unit test because that's outputting the actual C# source string. Changed the name `WordCategoriesMask` to avoid a conflict with existing member. Removed the detritus in the comments from the copy-paste from Emitter source (trailing `"` and `,`)
|
Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions Issue DetailsThere are four places the same mask is computed in this project, can't eliminate the one in RegexGenerator.Emitter or its matching unit test because that's outputting the actual C# source string. Changed the name Removed the detritus in the comments from the copy-paste from Emitter source (trailing
|
...ibraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCharClass.cs
Outdated
Show resolved
Hide resolved
…egularExpressions/RegexCharClass.cs Co-authored-by: Stephen Toub <[email protected]>
|
A follow-up couple of questions:
|
We did it this way to avoid code bloat with the code emitted into every assembly that uses it. If we hear of an issue with this, we can revisit, but I'm not aware of any. ECMA word boundaries are rare.
Only if it proves impactful. |
As noted in #84003, there are four places the same mask is computed in this project,. We can't eliminate the one in RegexGenerator.Emitter or its matching unit test because that's outputting the actual C# source string.
In the actual RegexCharClass.cs file changed the name
WordCategoriesMaskto avoid a conflict with existing member and added as a private constant. I also changed the Emitter and matching unit test to match for neatness.Removed the detritus in the comments from the copy-paste from Emitter source (trailing
"and,) and fixed the indentation error in the IsWordChar method.