Fixed unnecessary zero-length array allocations
Changed all currently present zero-length array allocations in the codebase to use `Array.Empty` instead.
This commit is contained in:
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.Cnc.Graphics
|
||||
|
||||
cachedPos = WPos.Zero;
|
||||
cachedLength = WVec.Zero;
|
||||
cache = new IFinalizedRenderable[] { };
|
||||
cache = Array.Empty<IFinalizedRenderable>();
|
||||
}
|
||||
|
||||
public WPos Pos => pos;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Primitives;
|
||||
@@ -32,7 +33,7 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
|
||||
Data = data;
|
||||
|
||||
if (data == null)
|
||||
Data = new byte[0];
|
||||
Data = Array.Empty<byte>();
|
||||
else
|
||||
Size = size;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Primitives;
|
||||
@@ -32,7 +33,7 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
|
||||
Data = data;
|
||||
|
||||
if (data == null)
|
||||
Data = new byte[0];
|
||||
Data = Array.Empty<byte>();
|
||||
else
|
||||
Size = size;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Primitives;
|
||||
@@ -109,7 +110,7 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
|
||||
}
|
||||
}
|
||||
else
|
||||
Data = new byte[0];
|
||||
Data = Array.Empty<byte>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
Game.ModData = destModData;
|
||||
var destPaletteInfo = destModData.DefaultRules.Actors[SystemActors.Player].TraitInfo<PlayerColorPaletteInfo>();
|
||||
var destRemapIndex = destPaletteInfo.RemapIndex;
|
||||
var shadowIndex = new int[] { };
|
||||
var shadowIndex = Array.Empty<int>();
|
||||
|
||||
// the remap range is always 16 entries, but their location and order changes
|
||||
for (var i = 0; i < 16; i++)
|
||||
|
||||
Reference in New Issue
Block a user