Cache the global mix database in MixLoader

We can reuse this global database as it doesn't change, rather than loading a new copy each time a new mix file is parsed.
This commit is contained in:
RoosterDragon
2022-01-29 20:23:52 +00:00
committed by reaperrr
parent f5d1fe4bc4
commit d8a4d7fd1d
2 changed files with 16 additions and 17 deletions

View File

@@ -10,7 +10,6 @@
#endregion
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using OpenRA.Mods.Cnc.FileFormats;
@@ -30,12 +29,11 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
[Desc("ARCHIVE.MIX", "MIXDATABASE.DAT", "Lists the content ranges for a mix file")]
void IUtilityCommand.Run(Utility utility, string[] args)
{
var allPossibleFilenames = new HashSet<string>();
string[] globalFilenames;
using (var db = new XccGlobalDatabase(File.OpenRead(args[2])))
foreach (var e in db.Entries)
allPossibleFilenames.Add(e);
globalFilenames = db.Entries;
var package = new MixLoader.MixFile(File.OpenRead(args[1]), args[1], allPossibleFilenames);
var package = new MixLoader.MixFile(File.OpenRead(args[1]), args[1], globalFilenames);
foreach (var kv in package.Index.OrderBy(kv => kv.Value.Offset))
{
Console.WriteLine("{0}:", kv.Key);