Avoid some allocations during loading.
- In FieldLoader, cache boxed bools and some boxed ints. - In FieldLoader, presize collections when parsing a List, HashSet or Dictionary. - In FieldLoader, don't allocate a list of missing items until required. - In FieldLoader, when a string value is passed, avoid wrapping this in a MiniYaml object by allowing both strings and yaml to be passed in the GetValue overload that does the real work. - In Animation, avoid allocating no-op actions. - In VxlReader, use EnsureCapcity to better size the Dictionary. - In VxlReader change VxlElement to a struct. - In Locomotor, presize TerrainSpeeds dictionary.
This commit is contained in:
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Cnc.Graphics
|
||||
sheetBuilder = CreateSheetBuilder();
|
||||
}
|
||||
|
||||
Vertex[] GenerateSlicePlane(int su, int sv, Func<int, int, VxlElement> first, Func<int, int, VxlElement> second, Func<int, int, float3> coord)
|
||||
Vertex[] GenerateSlicePlane(int su, int sv, Func<int, int, VxlElement?> first, Func<int, int, VxlElement?> second, Func<int, int, float3> coord)
|
||||
{
|
||||
var colors = new byte[su * sv];
|
||||
var normals = new byte[su * sv];
|
||||
@@ -68,8 +68,8 @@ namespace OpenRA.Mods.Cnc.Graphics
|
||||
for (var u = 0; u < su; u++)
|
||||
{
|
||||
var voxel = first(u, v) ?? second(u, v);
|
||||
colors[c] = voxel == null ? (byte)0 : voxel.Color;
|
||||
normals[c] = voxel == null ? (byte)0 : voxel.Normal;
|
||||
colors[c] = voxel == null ? (byte)0 : voxel.Value.Color;
|
||||
normals[c] = voxel == null ? (byte)0 : voxel.Value.Normal;
|
||||
c++;
|
||||
}
|
||||
}
|
||||
@@ -99,7 +99,7 @@ namespace OpenRA.Mods.Cnc.Graphics
|
||||
|
||||
IEnumerable<Vertex[]> GenerateSlicePlanes(VxlLimb l)
|
||||
{
|
||||
VxlElement Get(int x, int y, int z)
|
||||
VxlElement? Get(int x, int y, int z)
|
||||
{
|
||||
if (x < 0 || y < 0 || z < 0)
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user