Cache collections instead of looking them up for every single file.

This commit is contained in:
Ottermandias 2022-11-18 19:53:06 +01:00
parent f676bd1889
commit 2fac923452
12 changed files with 194 additions and 28 deletions

View file

@ -35,6 +35,8 @@ public class TempModManager
public bool CollectionByName( string name, [NotNullWhen( true )] out ModCollection? collection )
=> Collections.Values.FindFirst( c => string.Equals( c.Name, name, StringComparison.OrdinalIgnoreCase ), out collection );
public event ModCollection.Manager.CollectionChangeDelegate? CollectionChanged;
// These functions to check specific redirections or meta manipulations for existence are currently unused.
//public bool IsRegistered( string tag, ModCollection? collection, Utf8GamePath gamePath, out FullPath? fullPath, out int priority )
//{
@ -151,6 +153,7 @@ public class TempModManager
{
var collection = ModCollection.CreateNewTemporary( tag, characterName );
_collections[ characterName ] = collection;
CollectionChanged?.Invoke(CollectionType.Temporary, null, collection );
return collection.Name;
}
@ -160,6 +163,7 @@ public class TempModManager
{
_mods.Remove( c );
c.ClearCache();
CollectionChanged?.Invoke( CollectionType.Temporary, c, null );
return true;
}