Uh oh!
There was an error while loading. Please reload this page.
Simplify code emitted for single char repeater - #62322
Conversation
Rather than outputting an if block per unrolled iteration, just output a clause for each iteration as part of a single if block. We already do this for concatenations, but we don't yet for standalone repeaters.
ghost
commented
Dec 3, 2021
Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions Issue DetailsRather than outputting an if block per unrolled iteration, just output a clause for each iteration as part of a single if block. We already do this for concatenations, but we don't yet for standalone repeaters. e.g. for the expression if((uint)textSpan.Length<3){gotoNoMatch;}if(!char.IsDigit(textSpan[0])){gotoNoMatch;}if(!char.IsDigit(textSpan[1])){gotoNoMatch;}if(!char.IsDigit(textSpan[2])){gotoNoMatch;}and now we'll output if((uint)textSpan.Length<3||!char.IsDigit(textSpan[0])||!char.IsDigit(textSpan[1])||!char.IsDigit(textSpan[2])){gotoNoMatch;}cc: @joperezr
|
| { | ||
| EmitSingleChar(node, emitLengthCheck: false); | ||
| writer.WriteLine($"{SpanLengthCheck(iterations)} ||"); | ||
| writer.Write(" "); |
There was a problem hiding this comment.
As an aside comment, I've seen in some places in the emitter we just do:
writer.Indent+=4;// .. your indented writeswriter.Indent-=4;And we also have few places where we just write the spaces manually. If you agree, I'm happy to put up a PR that just normalizes to always use the Indent property to be consistent.
There was a problem hiding this comment.
I'm fine with whichever is more readable and maintainable. Places that currently manually indent looked subjectively better to my eyes, but it can be changed.
Rather than outputting an if block per unrolled iteration, just output a clause for each iteration as part of a single if block. We already do this for concatenations, but we don't yet for standalone repeaters.
e.g. for the expression
\d{3}, previously we would have output:and now we'll output
cc: @joperezr