forked from PGR/ascnet
1
0
Fork 0

TableReaderV2 caching

This commit is contained in:
rfi 2023-11-25 19:43:22 +07:00
parent f00e16c7a1
commit 11b470e77f
1 changed files with 9 additions and 0 deletions

View File

@ -37,10 +37,16 @@ namespace AscNet.Common.Util
public static class TableReaderV2
{
private static readonly Dictionary<Type, object> cache = new();
private static readonly Logger c = new(typeof(TableReaderV2), nameof(TableReaderV2), LogLevel.DEBUG, LogLevel.DEBUG);
public static List<T> Parse<T>() where T : ITable
{
if (cache.ContainsKey(typeof(T)))
{
return (List<T>)cache.GetValueOrDefault(typeof(T))!;
}
List<T> result = new();
try
@ -64,6 +70,9 @@ namespace AscNet.Common.Util
result.Add(obj);
}
}
c.Debug($"{typeof(T).Name} Loaded From {T.File}");
cache.Add(typeof(T), result);
}
catch (Exception ex)
{