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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user