Skip to content

Commit 664afd9

Browse files
committed
use sizeof for type size
1 parent 829c6b6 commit 664afd9

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

SteamKit2/SteamKit2/Util/StreamHelpers.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,55 +9,55 @@ internal static class StreamHelpers
99
{
1010
public static short ReadInt16(this Stream stream)
1111
{
12-
Span<byte> data = stackalloc byte[2];
12+
Span<byte> data = stackalloc byte[sizeof(Int16)];
1313

1414
stream.Read( data );
1515
return BitConverter.ToInt16( data );
1616
}
1717

1818
public static ushort ReadUInt16(this Stream stream)
1919
{
20-
Span<byte> data = stackalloc byte[2];
20+
Span<byte> data = stackalloc byte[sizeof(UInt16)];
2121

2222
stream.Read( data );
2323
return BitConverter.ToUInt16( data );
2424
}
2525

2626
public static int ReadInt32(this Stream stream)
2727
{
28-
Span<byte> data = stackalloc byte[4];
28+
Span<byte> data = stackalloc byte[sizeof(Int32)];
2929

3030
stream.Read( data );
3131
return BitConverter.ToInt32( data );
3232
}
3333

3434
public static long ReadInt64(this Stream stream)
3535
{
36-
Span<byte> data = stackalloc byte[8];
36+
Span<byte> data = stackalloc byte[sizeof(Int64)];
3737

3838
stream.Read( data );
3939
return BitConverter.ToInt64( data );
4040
}
4141

4242
public static uint ReadUInt32(this Stream stream)
4343
{
44-
Span<byte> data = stackalloc byte[4];
44+
Span<byte> data = stackalloc byte[sizeof(UInt32)];
4545

4646
stream.Read( data );
4747
return BitConverter.ToUInt32( data );
4848
}
4949

5050
public static ulong ReadUInt64(this Stream stream)
5151
{
52-
Span<byte> data = stackalloc byte[8];
52+
Span<byte> data = stackalloc byte[sizeof(UInt64)];
5353

5454
stream.Read( data );
5555
return BitConverter.ToUInt64( data );
5656
}
5757

5858
public static float ReadFloat( this Stream stream )
5959
{
60-
Span<byte> data = stackalloc byte[4];
60+
Span<byte> data = stackalloc byte[sizeof(float)];
6161

6262
stream.Read( data );
6363
return BitConverter.ToSingle( data );

0 commit comments

Comments
 (0)