mirror of
https://github.com/2dust/v2rayN.git
synced 2026-02-28 13:13:04 +00:00
Optimize ProfileItem acquisition speed
This commit is contained in:
parent
c6dd26e324
commit
9c20beb6da
2 changed files with 14 additions and 2 deletions
|
|
@ -98,9 +98,9 @@ public static class CoreConfigHandler
|
||||||
var ids = selecteds.Where(serverTestItem => !serverTestItem.IndexId.IsNullOrEmpty())
|
var ids = selecteds.Where(serverTestItem => !serverTestItem.IndexId.IsNullOrEmpty())
|
||||||
.Select(serverTestItem => serverTestItem.IndexId!)
|
.Select(serverTestItem => serverTestItem.IndexId!)
|
||||||
.ToList();
|
.ToList();
|
||||||
foreach (var id in ids)
|
var nodes = await AppManager.Instance.GetProfileItemsByIndexIds(ids);
|
||||||
|
foreach (var node in nodes)
|
||||||
{
|
{
|
||||||
var node = await AppManager.Instance.GetProfileItem(id) ?? new();
|
|
||||||
await FillNodeContext(context, node, false);
|
await FillNodeContext(context, node, false);
|
||||||
}
|
}
|
||||||
if (coreType == ECoreType.sing_box)
|
if (coreType == ECoreType.sing_box)
|
||||||
|
|
|
||||||
|
|
@ -230,6 +230,18 @@ public sealed class AppManager
|
||||||
return await SQLiteHelper.Instance.TableAsync<ProfileItem>().FirstOrDefaultAsync(it => it.IndexId == indexId);
|
return await SQLiteHelper.Instance.TableAsync<ProfileItem>().FirstOrDefaultAsync(it => it.IndexId == indexId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<List<ProfileItem>> GetProfileItemsByIndexIds(List<string> indexIds)
|
||||||
|
{
|
||||||
|
var ids = indexIds.Where(id => id.IsNotEmpty()).Distinct().ToList();
|
||||||
|
if (ids.Count == 0)
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return await SQLiteHelper.Instance.TableAsync<ProfileItem>()
|
||||||
|
.Where(it => ids.Contains(it.IndexId))
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<ProfileItem?> GetProfileItemViaRemarks(string? remarks)
|
public async Task<ProfileItem?> GetProfileItemViaRemarks(string? remarks)
|
||||||
{
|
{
|
||||||
if (remarks.IsNullOrEmpty())
|
if (remarks.IsNullOrEmpty())
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue