From aa6c9d91cf08b0adb7c3f61cd9d1d335ae755031 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Fri, 14 Mar 2025 16:42:54 +0800 Subject: [PATCH] Use string builder --- .../ProcessHelper.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs b/Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs index b409df2af..4c07341ec 100644 --- a/Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs +++ b/Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Text; using Windows.Win32; using Windows.Win32.Foundation; using Windows.Win32.System.Threading; @@ -31,15 +32,20 @@ namespace Flow.Launcher.Plugin.ProcessKiller private const string FlowLauncherProcessName = "Flow.Launcher"; - private bool IsSystemProcess(Process p) => _systemProcessList.Contains(p.ProcessName.ToLower()) || - string.Compare(p.ProcessName, FlowLauncherProcessName, StringComparison.OrdinalIgnoreCase) == 0; + private bool IsSystemProcessOrFlowLauncher(Process p) => + _systemProcessList.Contains(p.ProcessName.ToLower()) || + string.Equals(p.ProcessName, FlowLauncherProcessName, StringComparison.OrdinalIgnoreCase); /// /// Get title based on process name and id /// public static string GetProcessNameIdTitle(Process p) { - return p.ProcessName + " - " + p.Id; + var sb = new StringBuilder(); + sb.Append(p.ProcessName); + sb.Append(" - "); + sb.Append(p.Id); + return sb.ToString(); } /// @@ -51,7 +57,7 @@ namespace Flow.Launcher.Plugin.ProcessKiller foreach (var p in Process.GetProcesses()) { - if (IsSystemProcess(p)) continue; + if (IsSystemProcessOrFlowLauncher(p)) continue; processlist.Add(p); } @@ -110,7 +116,7 @@ namespace Flow.Launcher.Plugin.ProcessKiller /// public IEnumerable GetSimilarProcesses(string processPath) { - return Process.GetProcesses().Where(p => !IsSystemProcess(p) && TryGetProcessFilename(p) == processPath); + return Process.GetProcesses().Where(p => !IsSystemProcessOrFlowLauncher(p) && TryGetProcessFilename(p) == processPath); } public void TryKill(PluginInitContext context, Process p)