Slightly speed up uwp index

This commit is contained in:
Vic 2022-11-05 13:21:57 +08:00
parent cdde5fae2e
commit 1e8cc9afb5
2 changed files with 6 additions and 12 deletions

View file

@ -7,11 +7,10 @@ namespace Flow.Launcher.Plugin.Program.Programs
{
public class AppxPackageHelper
{
private static readonly IAppxFactory appxFactory = (IAppxFactory)new AppxFactory();
// This function returns a list of attributes of applications
public static List<IAppxManifestApplication> GetAppsFromManifest(IStream stream)
{
IAppxFactory appxFactory = (IAppxFactory)new AppxFactory();
List<IAppxManifestApplication> apps = new List<IAppxManifestApplication>();
var reader = appxFactory.CreateManifestReader(stream);
var manifestApps = reader.GetApplications();

View file

@ -41,8 +41,6 @@ namespace Flow.Launcher.Plugin.Program.Programs
FullName = package.Id.FullName;
FamilyName = package.Id.FamilyName;
InitializeAppInfo();
Apps = Apps.Where(a => !string.IsNullOrEmpty(a.UserModelId) && !string.IsNullOrEmpty(a.DisplayName))
.ToArray();
}
private void InitializeAppInfo()
@ -58,16 +56,13 @@ namespace Flow.Launcher.Plugin.Program.Programs
if (hResult == Hresult.Ok)
{
var apps = new List<Application>();
List<AppxPackageHelper.IAppxManifestApplication> _apps = AppxPackageHelper.GetAppsFromManifest(stream);
foreach (var _app in _apps)
{
var app = new Application(_app, this);
apps.Add(app);
}
Apps = apps.Where(a => a.AppListEntry != "none").ToArray();
Apps = _apps.Select(x => new Application(x, this))
.Where(a => a.AppListEntry != "none"
&& !string.IsNullOrEmpty(a.UserModelId)
&& !string.IsNullOrEmpty(a.DisplayName))
.ToArray();
}
else
{