Skip to content

Commit

Permalink
better performance: use BinaryReader.ReadBytes
Browse files Browse the repository at this point in the history
  • Loading branch information
akopetsch committed Jun 20, 2024
1 parent 6dae954 commit 2fb08ff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ByteSerialization/ByteSerialization.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Nullable>disable</Nullable>
<Authors>Alexander Kopetsch</Authors>
<Version>0.0.1.0</Version>
<PackageVersion>0.0.1-alpha.7</PackageVersion>
<PackageVersion>0.0.1-alpha.8</PackageVersion>
<PackageProjectUrl>https://github.com/akopetsch/ByteSerialization</PackageProjectUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
3 changes: 3 additions & 0 deletions ByteSerialization/IO/EndianBinaryReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ public Array Read(Type elementType, int count)
if (!elementType.IsBasicSerializable())
throw new ArgumentException();

if (elementType == typeof(byte))
return _reader.ReadBytes(count);

Array array = Array.CreateInstance(elementType, count);
for (int i = 0; i < count; i++)
array.SetValue(Read(elementType), i);
Expand Down

0 comments on commit 2fb08ff

Please sign in to comment.