boost up gacha statistics view speed 2x

This commit is contained in:
DismissedLight
2023-09-08 20:53:06 +08:00
committed by Lightczx
parent d3ea7cf8ac
commit ecd535f9a0
3 changed files with 10 additions and 21 deletions

View File

@@ -8,6 +8,7 @@ using Snap.Hutao.Model.Metadata.Avatar;
using Snap.Hutao.Model.Metadata.Weapon;
using Snap.Hutao.Service.Metadata;
using Snap.Hutao.ViewModel.GachaLog;
using Snap.Hutao.Web.Hoyolab.Hk4e.Event.GachaInfo;
using Snap.Hutao.Web.Hutao.GachaLog;
using System.Runtime.InteropServices;
@@ -59,14 +60,19 @@ internal sealed partial class GachaStatisticsFactory : IGachaStatisticsFactory
Dictionary<Weapon, int> purpleWeaponCounter = new();
Dictionary<Weapon, int> blueWeaponCounter = new();
// Pre group builders
Dictionary<GachaConfigType, List<HistoryWishBuilder>> historyWishBuilderMap = historyWishBuilders
.GroupBy(b => b.ConfigType)
.ToDictionary(g => g.Key, g => g.ToList().SortBy(b => b.From));
// Items are ordered by precise time, first is oldest
// 'ref' is not allowed here because we have lambda below
foreach (Model.Entity.GachaItem item in CollectionsMarshal.AsSpan(items))
{
// Find target history wish to operate.
HistoryWishBuilder? targetHistoryWishBuilder = historyWishBuilders
.Where(w => w.ConfigType == item.GachaType)
.SingleOrDefault(w => w.From <= item.Time && w.To >= item.Time);
HistoryWishBuilder? targetHistoryWishBuilder = item.GachaType is not GachaConfigType.StandardWish
? historyWishBuilderMap[item.GachaType].FirstOrDefault(w => w.From <= item.Time && w.To >= item.Time)
: default;
switch (item.ItemId.StringLength())
{

View File

@@ -184,7 +184,7 @@ internal sealed partial class GameService : IGameService
{
GameResource resource = response.Data;
if (!LaunchSchemeMatchesExecutable(launchScheme, gameFileName))
if (!launchScheme.ExecutableMatches(gameFileName))
{
bool replaced = await packageConverter
.EnsureGameResourceAsync(launchScheme, resource, gameFolder, progress)
@@ -398,6 +398,4 @@ internal sealed partial class GameService : IGameService
_ => false,
};
}
private static bool LaunchScheme
}

View File

@@ -75,19 +75,4 @@ internal sealed partial class LaunchScheme
_ => false,
};
}
public bool SdkLibraryMatches(string gameFolder)
{
if (IsOversea)
{
return false;
}
if (LauncherId is SdkStaticLauncherBilibiliId)
{
}
string sdkDll = Path.Combine(gameFolder, GameConstants.YuanShenData, "Plugins\\PCGameSDK.dll");
}
}