Currently System.Linq uses this pattern to handle invalid arguments:
if (source == null)
{
throw Error.ArgumentNull(nameof(source));
}
Where ArgumentNull gets inlined. This introduces significant jitted code bloat since the Linq methods are generic, so this code (which very rarely gets hit) is generated over and over again for different value types.
We should convert all of this to the form
if (source == null)
{
Error.ThrowSourceArgumentNull(); // or ThrowArgumentNullSource
}
As of dotnet/coreclr#6103 methods that are known to throw are not inlined, so this should help decrease code size.
cc @benaadams
Currently System.Linq uses this pattern to handle invalid arguments:
Where
ArgumentNullgets inlined. This introduces significant jitted code bloat since the Linq methods are generic, so this code (which very rarely gets hit) is generated over and over again for different value types.We should convert all of this to the form
As of dotnet/coreclr#6103 methods that are known to throw are not inlined, so this should help decrease code size.
cc @benaadams