mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
cut memory usange in half using string interning, most of the Basic Fixes pack compiles
This commit is contained in:
parent
c343a74359
commit
14bb629b8a
@ -68,12 +68,9 @@ namespace VFS
|
||||
public IList<VirtualFile> FilesInArchive(VirtualFile f)
|
||||
{
|
||||
var path = f.FullPath + "|";
|
||||
lock (this)
|
||||
{
|
||||
return _files.Values
|
||||
.Where(v => v.FullPath.StartsWith(path))
|
||||
.ToList();
|
||||
}
|
||||
return _files.Values
|
||||
.Where(v => v.FullPath.StartsWith(path))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
||||
@ -358,8 +355,21 @@ namespace VFS
|
||||
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
|
||||
public class VirtualFile
|
||||
{
|
||||
public string[] _paths;
|
||||
[JsonProperty]
|
||||
public string[] Paths { get; set; }
|
||||
public string[] Paths
|
||||
{
|
||||
get
|
||||
{
|
||||
return _paths;
|
||||
}
|
||||
set
|
||||
{
|
||||
for (int idx = 0; idx < value.Length; idx += 1)
|
||||
value[idx] = String.Intern(value[idx]);
|
||||
_paths = value;
|
||||
}
|
||||
}
|
||||
[JsonProperty]
|
||||
public string Hash { get; set; }
|
||||
[JsonProperty]
|
||||
|
@ -130,6 +130,7 @@ namespace Wabbajack
|
||||
|
||||
public AppState(Dispatcher d, String mode)
|
||||
{
|
||||
_startTime = DateTime.Now;
|
||||
ArchiveFile.SetupLibrary();
|
||||
LogFile = Assembly.GetExecutingAssembly().Location + ".log";
|
||||
|
||||
@ -186,6 +187,7 @@ namespace Wabbajack
|
||||
|
||||
public void LogMsg(string msg)
|
||||
{
|
||||
msg = $"{(DateTime.Now - _startTime).TotalSeconds:0.##} - {msg}";
|
||||
dispatcher.Invoke(() => Log.Add(msg));
|
||||
lock (dispatcher) {
|
||||
File.AppendAllText(LogFile, msg + "\r\n");
|
||||
@ -264,6 +266,8 @@ namespace Wabbajack
|
||||
}
|
||||
|
||||
private ICommand _begin;
|
||||
private DateTime _startTime;
|
||||
|
||||
public ICommand Begin
|
||||
{
|
||||
get
|
||||
|
@ -137,17 +137,21 @@ namespace Wabbajack
|
||||
|
||||
public void Compile()
|
||||
{
|
||||
Info($"Indexing {MO2Folder}");
|
||||
VFS.AddRoot(MO2Folder);
|
||||
Info($"Indexing {GamePath}");
|
||||
VFS.AddRoot(GamePath);
|
||||
|
||||
var mo2_files = Directory.EnumerateFiles(MO2Folder, "*", SearchOption.AllDirectories)
|
||||
.Where(p => p.FileExists())
|
||||
.Select(p => new RawSourceFile(VFS.Lookup(p)));
|
||||
.Select(p => new RawSourceFile(VFS.Lookup(p)) { Path = p.RelativeTo(MO2Folder)});
|
||||
|
||||
var game_files = Directory.EnumerateFiles(GamePath, "*", SearchOption.AllDirectories)
|
||||
.Where(p => p.FileExists())
|
||||
.Select(p => new RawSourceFile(VFS.Lookup(p)) { Path = Path.Combine(Consts.GameFolderFilesDir, p.RelativeTo(GamePath))});
|
||||
|
||||
|
||||
Info($"Indexing Archives");
|
||||
IndexedArchives = Directory.EnumerateFiles(MO2DownloadsFolder)
|
||||
.Where(f => Consts.SupportedArchives.Contains(Path.GetExtension(f)))
|
||||
.Where(f => File.Exists(f + ".meta"))
|
||||
@ -159,7 +163,10 @@ namespace Wabbajack
|
||||
})
|
||||
.ToList();
|
||||
|
||||
IndexedFiles = IndexedArchives.SelectMany(f => VFS.FilesInArchive(f.File))
|
||||
Info($"Indexing Files");
|
||||
IndexedFiles = IndexedArchives.PMap(f => { Status($"Finding files in {Path.GetFileName(f.File.FullPath)}");
|
||||
return VFS.FilesInArchive(f.File); })
|
||||
.SelectMany(fs => fs)
|
||||
.OrderByDescending(f => f.TopLevelArchive.LastModified)
|
||||
.GroupBy(f => f.Hash)
|
||||
.ToDictionary(f => f.Key, f => f.AsEnumerable());
|
||||
|
Loading…
Reference in New Issue
Block a user