A few more Enum perf improvements (dotnet/coreclr#21284)
authorStephen Toub <stoub@microsoft.com>
Fri, 30 Nov 2018 15:16:25 +0000 (10:16 -0500)
committerGitHub <noreply@github.com>
Fri, 30 Nov 2018 15:16:25 +0000 (10:16 -0500)
commitcb5a55fa85234ec21aaa52d7f1942abd895f7c05
treef6c0a71aeeb1dfe8f722c204de61cce58423a344
parentcd736dc613d6ee16af2159017284ab654428425a
A few more Enum perf improvements (dotnet/coreclr#21284)

* A few more Enum perf improvements

I started out to just remove the unnecessary boxing allocation that happens when you do enum.ToString("D") or, if the value doesn't map to a named enum entry, just enum.ToString() (there's an internal boxing of the value that happens in addition to any boxing that happens of the enum itself).  As part of that, I added a ValueToString method that replaces the GetValue().ToString() calls that appear several times, and in writing that ValueToString, I opted to avoid pinning, instead using Unsafe.As.  Once I did that, I then removed pinning everywhere else it was being done, standardizing on Unsafe.As.

* Address PR feedback

Commit migrated from https://github.com/dotnet/coreclr/commit/7972722e3a3788fe96056d0a5398f90466588b8f
src/coreclr/src/System.Private.CoreLib/ILLinkTrim.xml
src/coreclr/src/System.Private.CoreLib/src/System/Enum.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs
src/coreclr/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs
src/coreclr/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/jithelpers.cs
src/coreclr/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIPropertyValueImpl.cs