mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Refactor non-global plugin retrieval for performance optimization
Refactored plugin lookup in ValidPluginsForQuery to use a new TryGetNonGlobalPlugins method, which safely copies plugin lists using a lock. This improves thread safety and performance when accessing non-global plugins.
This commit is contained in:
parent
baa3a690a3
commit
88ac19af76
1 changed files with 15 additions and 1 deletions
|
|
@ -380,7 +380,7 @@ namespace Flow.Launcher.Core.Plugin
|
|||
if (query is null)
|
||||
return Array.Empty<PluginPair>();
|
||||
|
||||
if (!GetNonGlobalPlugins().TryGetValue(query.ActionKeyword, out var plugins))
|
||||
if (TryGetNonGlobalPlugins(query.ActionKeyword, out var plugins))
|
||||
{
|
||||
if (dialogJump)
|
||||
return [.. GetGlobalPlugins().Where(p => p.Plugin is IAsyncDialogJump && !PluginModified(p.Metadata.ID))];
|
||||
|
|
@ -395,6 +395,20 @@ namespace Flow.Launcher.Core.Plugin
|
|||
return [.. validPlugins];
|
||||
}
|
||||
|
||||
private static bool TryGetNonGlobalPlugins(string actionKeyword, out List<PluginPair> plugins)
|
||||
{
|
||||
if (_nonGlobalPlugins.TryGetValue(actionKeyword, out var list))
|
||||
{
|
||||
lock (list)
|
||||
{
|
||||
plugins = [.. list];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
plugins = [];
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ICollection<PluginPair> ValidPluginsForHomeQuery()
|
||||
{
|
||||
return [.. _homePlugins.Where(p => !PluginModified(p.Metadata.ID))];
|
||||
|
|
|
|||
Loading…
Reference in a new issue