-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Remove leftover runtextbeg/end references from RegexCompiler / source generator #66129
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
… generator Now that we're operating over a span that represents the full input from beginning to end, we no longer need to access runtextbeg/runtextend, we can use inputSpan.Slice(pos) instead of inputSpan.Slice(pos, end - pos), etc.
|
Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions Issue DetailsNow that we're operating over a span that represents the full input from beginning to end, we no longer need to access runtextbeg/runtextend, we can use inputSpan.Slice(pos) instead of inputSpan.Slice(pos, end - pos), etc.
|
| { | ||
| writer.WriteLine("int newlinePos = global::System.MemoryExtensions.IndexOf(inputSpan.Slice(pos), '\\n');"); | ||
| using (EmitBlock(writer, "if (newlinePos < 0 || newlinePos + pos + 1 > end)")) | ||
| using (EmitBlock(writer, "if ((uint)newlinePos > inputSpan.Length - pos - 1)")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: I like the condensed check here, but I wonder if it might be harder to read than what we used to have. Would it make sense to add a comment above the if-block with the writer so that it is easier to understand for people when debugging the source generated code? If you think the check is to obvious as to what it is doing then I'm fine without a comment.
| TransferSliceStaticPosToPos(); | ||
| Ldloc(end); | ||
| Ldloca(inputSpan); | ||
| Call(s_spanGetLengthMethod); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: Since we do this a lot now, should we consider a Macro that does the inputSpan.Length similar to how we have one for SliceInputSpan?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are already a bunch of places where we get a span's length. If you think it's worth adding a helper for, we can go back through after and replace each pair of two calls with one call.
joperezr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
![]()
|
Improvements on alpine-x64 dotnet/perf-autofiling-issues#3976 |
Now that we're operating over a span that represents the full input from beginning to end, we no longer need to access runtextbeg/runtextend, we can use inputSpan.Slice(pos) instead of inputSpan.Slice(pos, end - pos), etc.