PointerToolkit icon indicating copy to clipboard operation
PointerToolkit copied to clipboard

Fix up IL of As() and AsPointer() to match the real Unsafe

Open rickbrew opened this issue 4 years ago • 0 comments

See reference implementations here: https://github.com/dotnet/runtime/blob/main/src/libraries/System.Runtime.CompilerServices.Unsafe/src/System.Runtime.CompilerServices.Unsafe.il

and here: https://github.com/ltrzesniewski/InlineIL.Fody/blob/master/src/InlineIL.Examples/Unsafe.cs

Notice how AsPointer() uses conv.u and the other As() methods that return a ref are slightly different.

This may not make a difference in how the code runs but it may improve inlining. Might need to ask an expert for a review here.

rickbrew avatar Jan 05 '22 01:01 rickbrew