E.g. for
static bool M1(int x) => x is < 100 or > 511;
code similar to
if (x >= 100)
{
return x > 511;
}
return true;
is generated. This could be optimized to
return (uint)(x - 100) > 411u;
which should be faster and less machine code (as well IL code) on all platforms, by avoiding an extra comparison and jump.
JIT could do this too, but JIT is a live-compiler (also applies to tiered compilation), and Roslyn is recognizing the is pattern anyway.
E.g. for
code similar to
is generated. This could be optimized to
which should be faster and less machine code (as well IL code) on all platforms, by avoiding an extra comparison and jump.
JIT could do this too, but JIT is a live-compiler (also applies to tiered compilation), and Roslyn is recognizing the
ispattern anyway.