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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private static string Replace(MatchEvaluator evaluator, Regex regex, string inpu

if (!regex.RightToLeft)
{
regex.Run(input, startat, ref state, (ref (SegmentStringBuilder segments, MatchEvaluator evaluator, int prevat, string input, int count) state, Match match) =>
regex.Run(input, startat, ref state, static (ref (SegmentStringBuilder segments, MatchEvaluator evaluator, int prevat, string input, int count) state, Match match) =>
{
state.segments.Add(state.input.AsMemory(state.prevat, match.Index - state.prevat));
state.prevat = match.Index + match.Length;
Expand All @@ -193,11 +193,11 @@ private static string Replace(MatchEvaluator evaluator, Regex regex, string inpu
{
state.prevat = input.Length;

regex.Run(input, startat, ref state, (ref (SegmentStringBuilder segments, MatchEvaluator evaluator, int prevat, string input, int count) state, Match match) =>
regex.Run(input, startat, ref state, static (ref (SegmentStringBuilder segments, MatchEvaluator evaluator, int prevat, string input, int count) state, Match match) =>
{
state.segments.Add(state.input.AsMemory(match.Index + match.Length, state.prevat - match.Index - match.Length));
state.prevat = match.Index;
state.segments.Add(evaluator(match).AsMemory());
state.segments.Add(state.evaluator(match).AsMemory());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the fix.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious about how you found this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wednesdays are a busy meeting day for me, and I find my mind is able to stay more focused on them if I give it little mindless side projects, like walking in ILSpy through all "DisplayClass"es in all of netcoreapp looking for ones that don't belong :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next task is to look a dumps all day.

return --state.count != 0;
}, reuseMatchObject: false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private static string[] Split(Regex regex, string input, int count, int startat)

if (!regex.RightToLeft)
{
regex.Run(input, startat, ref state, (ref (List<string> results, int prevat, string input, int count) state, Match match) =>
regex.Run(input, startat, ref state, static (ref (List<string> results, int prevat, string input, int count) state, Match match) =>
{
state.results.Add(state.input.Substring(state.prevat, match.Index - state.prevat));
state.prevat = match.Index + match.Length;
Expand Down Expand Up @@ -117,7 +117,7 @@ private static string[] Split(Regex regex, string input, int count, int startat)
{
state.prevat = input.Length;

regex.Run(input, startat, ref state, (ref (List<string> results, int prevat, string input, int count) state, Match match) =>
regex.Run(input, startat, ref state, static (ref (List<string> results, int prevat, string input, int count) state, Match match) =>
{
state.results.Add(state.input.Substring(match.Index + match.Length, state.prevat - match.Index - match.Length));
state.prevat = match.Index;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ public static string ConvertOldStringsToClass(string set, string category)
strLength -= 2;
}

return string.Create(strLength, (set, category, startsWithNulls), (span, state) =>
return string.Create(strLength, (set, category, startsWithNulls), static (span, state) =>
{
int index;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ protected void GenerateFindFirstChar()
{
// Create a string to store the lookup table we use to find the offset.
Debug.Assert(_boyerMoorePrefix.Pattern.Length <= char.MaxValue, "RegexBoyerMoore should have limited the size allowed.");
string negativeLookup = string.Create(negativeRange, (thisRef: this, beforefirst), (span, state) =>
string negativeLookup = string.Create(negativeRange, (thisRef: this, beforefirst), static (span, state) =>
{
// Store the offsets into the string. RightToLeft has negative offsets, so to support it with chars (unsigned), we negate
// the values to be stored in the string, and then at run time after looking up the offset in the string, negate it again.
Expand Down Expand Up @@ -5256,7 +5256,7 @@ void EmitCharInClass()

// Generate the lookup table to store 128 answers as bits. We use a const string instead of a byte[] / static
// data property because it lets IL emit handle all the details for us.
string bitVectorString = string.Create(8, (charClass, invariant), (dest, state) => // String length is 8 chars == 16 bytes == 128 bits.
string bitVectorString = string.Create(8, (charClass, invariant), static (dest, state) => // String length is 8 chars == 16 bytes == 128 bits.
{
for (int i = 0; i < 128; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2134,7 +2134,7 @@ private void AddConcatenate(int pos, int cch, bool isReplacement)
if (cch > 1)
{
string str = UseOptionI() && !isReplacement ?
string.Create(cch, (_pattern, _culture, pos, cch), (span, state) => state._pattern.AsSpan(state.pos, state.cch).ToLower(span, state._culture)) :
string.Create(cch, (_pattern, _culture, pos, cch), static (span, state) => state._pattern.AsSpan(state.pos, state.cch).ToLower(span, state._culture)) :
_pattern.Substring(pos, cch);

node = new RegexNode(RegexNode.Multi, _options, str);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public override string ToString()
length += span[i].Length;
}

string result = string.Create(length, this, (dest, builder) =>
string result = string.Create(length, this, static (dest, builder) =>
{
Span<ReadOnlyMemory<char>> localSpan = builder.AsSpan();
for (int i = 0; i < localSpan.Length; i++)
Expand Down