Skip to content

Commit 5ef590e

Browse files
committed
Use Array.Empty<>() when constructing new array tags
1 parent cda7474 commit 5ef590e

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

fNbt/Tags/NbtByteArray.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
namespace fNbt {
77
/// <summary> A tag containing an array of bytes. </summary>
88
public sealed class NbtByteArray : NbtTag {
9-
static readonly byte[] ZeroArray = new byte[0];
10-
119
/// <summary> Type of this tag (ByteArray). </summary>
1210
public override NbtTagType TagType {
1311
get { return NbtTagType.ByteArray; }
@@ -48,7 +46,7 @@ public NbtByteArray([NotNull] byte[] value)
4846
/// <param name="tagName"> Name to assign to this tag. May be <c>null</c>. </param>
4947
public NbtByteArray([CanBeNull] string tagName) {
5048
name = tagName;
51-
bytes = ZeroArray;
49+
bytes = Array.Empty<byte>();
5250
}
5351

5452

fNbt/Tags/NbtIntArray.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
namespace fNbt {
66
/// <summary> A tag containing an array of signed 32-bit integers. </summary>
77
public sealed class NbtIntArray : NbtTag {
8-
static readonly int[] ZeroArray = new int[0];
9-
108
/// <summary> Type of this tag (ByteArray). </summary>
119
public override NbtTagType TagType {
1210
get { return NbtTagType.IntArray; }
@@ -47,7 +45,7 @@ public NbtIntArray([NotNull] int[] value)
4745
/// <param name="tagName"> Name to assign to this tag. May be <c>null</c>. </param>
4846
public NbtIntArray([CanBeNull] string tagName) {
4947
name = tagName;
50-
ints = ZeroArray;
48+
ints = Array.Empty<int>();
5149
}
5250

5351

fNbt/Tags/NbtLongArray.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public NbtLongArray([NotNull] long[] value)
4848
/// <param name="tagName"> Name to assign to this tag. May be <c>null</c>. </param>
4949
public NbtLongArray([CanBeNull] string tagName) {
5050
name = tagName;
51-
longs = new long[0];
51+
longs = Array.Empty<long>();
5252
}
5353

5454
/// <summary> Creates an NbtLongArray tag with the given name, containing the given array of longs. </summary>

0 commit comments

Comments
 (0)