class C
{
static bool IsWhiteSpace(char c) => IsLatin1(c);
static bool IsLatin1(char c) => c < RVA.Length;
static ReadOnlySpan<byte> RVA => new byte[]{1,2,3};
}
codegen for IsWhiteSpace:
; Method C:IsWhiteSpace(ushort):bool
movzx rcx, cx
tail.jmp [C:IsLatin1(ushort):bool]
; Total bytes of code: 9
weight= 10 : state 3 [ ldarg.0 ]
weight= 79 : state 40 [ call ]
weight= 6 : state 11 [ stloc.0 ]
Named Intrinsic System.ReadOnlySpan`1.get_Length: Recognized
weight= 61 : state 19 [ ldloca.s ]
weight= 79 : state 40 [ call ]
weight= 26 : state 171 [ clt ]
weight= 19 : state 42 [ ret ]
Inline has 1 intrinsics. Multiplier increased to 1.3.
Inline candidate callsite is boring. Multiplier increased to 2.6.
calleeNativeSizeEstimate=280
callsiteNativeSizeEstimate=85
benefit multiplier=2.6
threshold=221
Native estimate for function size exceeds threshold for inlining 28 > 22.1 (multiplier = 2.6)
The IL for RVA spans is a bit verbose, inliner sees two calls (one of them is recognized as Span.Length though) and is not able to predict that the whole thing is lowered to a few instructions
codegen for
IsWhiteSpace:The IL for RVA spans is a bit verbose, inliner sees two calls (one of them is recognized as Span.Length though) and is not able to predict that the whole thing is lowered to a few instructions