mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Use Generic to remove duplicate query
This commit is contained in:
parent
24ce10183e
commit
86edae2bc6
1 changed files with 15 additions and 21 deletions
|
|
@ -71,21 +71,17 @@ namespace Flow.Launcher.Plugin.Program
|
|||
Win32[] win32;
|
||||
UWP.Application[] uwps;
|
||||
|
||||
lock (IndexLock)
|
||||
{ // just take the reference inside the lock to eliminate query time issues.
|
||||
win32 = _win32s;
|
||||
uwps = _uwps;
|
||||
}
|
||||
win32 = _win32s;
|
||||
uwps = _uwps;
|
||||
|
||||
var results1 = win32.AsParallel()
|
||||
.Where(p => p.Enabled)
|
||||
.Select(p => p.Result(query.Search, _context.API));
|
||||
var result = win32.Cast<IProgram>()
|
||||
.Concat(uwps)
|
||||
.AsParallel()
|
||||
.Where(p => p.Enabled)
|
||||
.Select(p => p.Result(query.Search, _context.API))
|
||||
.Where(r => r?.Score > 0)
|
||||
.ToList();
|
||||
|
||||
var results2 = uwps.AsParallel()
|
||||
.Where(p => p.Enabled)
|
||||
.Select(p => p.Result(query.Search, _context.API));
|
||||
|
||||
var result = results1.Concat(results2).Where(r => r != null && r.Score > 0).ToList();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -97,10 +93,9 @@ namespace Flow.Launcher.Plugin.Program
|
|||
public static void IndexWin32Programs()
|
||||
{
|
||||
var win32S = Win32.All(_settings);
|
||||
lock (IndexLock)
|
||||
{
|
||||
_win32s = win32S;
|
||||
}
|
||||
|
||||
_win32s = win32S;
|
||||
|
||||
}
|
||||
|
||||
public static void IndexUWPPrograms()
|
||||
|
|
@ -109,10 +104,9 @@ namespace Flow.Launcher.Plugin.Program
|
|||
var support = Environment.OSVersion.Version.Major >= windows10.Major;
|
||||
|
||||
var applications = support ? UWP.All() : new UWP.Application[] { };
|
||||
lock (IndexLock)
|
||||
{
|
||||
_uwps = applications;
|
||||
}
|
||||
|
||||
_uwps = applications;
|
||||
|
||||
}
|
||||
|
||||
public static void IndexPrograms()
|
||||
|
|
|
|||
Loading…
Reference in a new issue