Skip to content

Commit

Permalink
use sizeof for type size
Browse files Browse the repository at this point in the history
  • Loading branch information
yaakov-h committed Jun 30, 2024
1 parent 829c6b6 commit 664afd9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions SteamKit2/SteamKit2/Util/StreamHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,55 +9,55 @@ internal static class StreamHelpers
{
public static short ReadInt16(this Stream stream)
{
Span<byte> data = stackalloc byte[2];
Span<byte> data = stackalloc byte[sizeof(Int16)];

stream.Read( data );
return BitConverter.ToInt16( data );
}

public static ushort ReadUInt16(this Stream stream)
{
Span<byte> data = stackalloc byte[2];
Span<byte> data = stackalloc byte[sizeof(UInt16)];

stream.Read( data );
return BitConverter.ToUInt16( data );
}

public static int ReadInt32(this Stream stream)
{
Span<byte> data = stackalloc byte[4];
Span<byte> data = stackalloc byte[sizeof(Int32)];

stream.Read( data );
return BitConverter.ToInt32( data );
}

public static long ReadInt64(this Stream stream)
{
Span<byte> data = stackalloc byte[8];
Span<byte> data = stackalloc byte[sizeof(Int64)];

stream.Read( data );
return BitConverter.ToInt64( data );
}

public static uint ReadUInt32(this Stream stream)
{
Span<byte> data = stackalloc byte[4];
Span<byte> data = stackalloc byte[sizeof(UInt32)];

stream.Read( data );
return BitConverter.ToUInt32( data );
}

public static ulong ReadUInt64(this Stream stream)
{
Span<byte> data = stackalloc byte[8];
Span<byte> data = stackalloc byte[sizeof(UInt64)];

stream.Read( data );
return BitConverter.ToUInt64( data );
}

public static float ReadFloat( this Stream stream )
{
Span<byte> data = stackalloc byte[4];
Span<byte> data = stackalloc byte[sizeof(float)];

stream.Read( data );
return BitConverter.ToSingle( data );
Expand Down

0 comments on commit 664afd9

Please sign in to comment.