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 System.IO;
|
||||
using System.Linq;
|
||||
@@ -35,7 +36,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
Console.WriteLine($"ERROR: Detected NewINIFormat {format}. Are you trying to import a Red Alert map?");
|
||||
}
|
||||
|
||||
static readonly Dictionary<string, (byte Type, byte Index)> OverlayResourceMapping = new()
|
||||
static readonly FrozenDictionary<string, (byte Type, byte Index)> OverlayResourceMapping = new Dictionary<string, (byte Type, byte Index)>
|
||||
{
|
||||
// Tiberium
|
||||
{ "ti1", (1, 0) },
|
||||
@@ -50,7 +51,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
{ "ti10", (1, 9) },
|
||||
{ "ti11", (1, 10) },
|
||||
{ "ti12", (1, 11) },
|
||||
};
|
||||
}.ToFrozenDictionary();
|
||||
|
||||
void UnpackTileData(Stream ms)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user