Use BitConverter.Int32BitsToSingle in SpanReaderExtensions

This commit is contained in:
js6pak committed 2021-04-03 00:12:15 +02:00
1 parent 11e87e51db
commit 989b06d04c
1 file changed
+1 -9
@@ -35,9 +35,7 @@ namespace Impostor.Api
{
var original = Advance<float>(ref input);
// BitConverter.Int32BitsToSingle
// Doesn't exist in net 2.0 for some reason
return Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(original));
return BitConverter.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(original));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -46,12 +44,6 @@ namespace Impostor.Api
return input.ReadByte() != 0;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static unsafe float Int32BitsToSingle(int value)
{
return *((float*)&value);
}
/// <summary>
/// Advances the position of <paramref name="input" /> by the size of <typeparamref name="T" />.
/// </summary>