Freeze non-mutable readonly static dictionaries.
Since these will live for the lifetime of the process, it is worth freezing them on creation to improve lookup performance. If the dictionaries were iterated, change to an immutable array instead to preserve the order.
This commit is contained in:
committed by
Gustas Kažukauskas
parent
f4eb5739d6
commit
9e548fd0f0
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Frozen;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
@@ -42,7 +43,7 @@ namespace OpenRA.Mods.D2k.Traits
|
||||
All = Left | Top | Right | Bottom | TopLeft | TopRight | BottomLeft | BottomRight
|
||||
}
|
||||
|
||||
public static readonly Dictionary<ClearSides, int> SpriteMap = new()
|
||||
public static readonly FrozenDictionary<ClearSides, int> SpriteMap = new Dictionary<ClearSides, int>
|
||||
{
|
||||
{ ClearSides.Left | ClearSides.Top | ClearSides.TopLeft | ClearSides.TopRight | ClearSides.BottomLeft | ClearSides.BottomRight, 2 },
|
||||
{ ClearSides.Top | ClearSides.Right | ClearSides.TopLeft | ClearSides.TopRight | ClearSides.BottomLeft | ClearSides.BottomRight, 3 },
|
||||
@@ -90,7 +91,7 @@ namespace OpenRA.Mods.D2k.Traits
|
||||
{ ClearSides.Right | ClearSides.TopLeft | ClearSides.TopRight | ClearSides.BottomRight, 47 },
|
||||
{ ClearSides.Bottom | ClearSides.TopRight | ClearSides.BottomLeft | ClearSides.BottomRight, 48 },
|
||||
{ ClearSides.Bottom | ClearSides.TopLeft | ClearSides.BottomLeft | ClearSides.BottomRight, 49 },
|
||||
};
|
||||
}.ToFrozenDictionary();
|
||||
|
||||
public D2kResourceRenderer(Actor self, D2kResourceRendererInfo info)
|
||||
: base(self, info) { }
|
||||
|
||||
Reference in New Issue
Block a user