Let's say we have a value type like this, where the fields are readonly
and initialized during construction:
public struct SomeValue
{
private readonly Int32 field1;
private readonly Int32 field2;
...
}
Also, let's say we have a helper class that lets us implement GetHashCode()
for composite types in a reusable manner:
public struct SomeValue
{
...
public override Int32 GetHashCode()
{
return HashHelpers.GetHashCode(this.field1, this.field2);
}
}
Now, the compiler must realize that the field values aren't ever going to change after the type is constructed, since they are readonly
. Is it therefore likely that the call to HashHelpers.GetHashCode()
will somehow be inlined when SomeValue.GetHashCode()
is JIT-ed?