Skip to content

Commit aa6c9d9

Browse files
committed
Use string builder
1 parent f25c5b9 commit aa6c9d9

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Collections.Generic;
44
using System.Diagnostics;
55
using System.Linq;
6+
using System.Text;
67
using Windows.Win32;
78
using Windows.Win32.Foundation;
89
using Windows.Win32.System.Threading;
@@ -31,15 +32,20 @@ internal class ProcessHelper
3132

3233
private const string FlowLauncherProcessName = "Flow.Launcher";
3334

34-
private bool IsSystemProcess(Process p) => _systemProcessList.Contains(p.ProcessName.ToLower()) ||
35-
string.Compare(p.ProcessName, FlowLauncherProcessName, StringComparison.OrdinalIgnoreCase) == 0;
35+
private bool IsSystemProcessOrFlowLauncher(Process p) =>
36+
_systemProcessList.Contains(p.ProcessName.ToLower()) ||
37+
string.Equals(p.ProcessName, FlowLauncherProcessName, StringComparison.OrdinalIgnoreCase);
3638

3739
/// <summary>
3840
/// Get title based on process name and id
3941
/// </summary>
4042
public static string GetProcessNameIdTitle(Process p)
4143
{
42-
return p.ProcessName + " - " + p.Id;
44+
var sb = new StringBuilder();
45+
sb.Append(p.ProcessName);
46+
sb.Append(" - ");
47+
sb.Append(p.Id);
48+
return sb.ToString();
4349
}
4450

4551
/// <summary>
@@ -51,7 +57,7 @@ public List<Process> GetMatchingProcesses()
5157

5258
foreach (var p in Process.GetProcesses())
5359
{
54-
if (IsSystemProcess(p)) continue;
60+
if (IsSystemProcessOrFlowLauncher(p)) continue;
5561

5662
processlist.Add(p);
5763
}
@@ -110,7 +116,7 @@ private static unsafe string GetWindowTitle(HWND hwnd)
110116
/// </summary>
111117
public IEnumerable<Process> GetSimilarProcesses(string processPath)
112118
{
113-
return Process.GetProcesses().Where(p => !IsSystemProcess(p) && TryGetProcessFilename(p) == processPath);
119+
return Process.GetProcesses().Where(p => !IsSystemProcessOrFlowLauncher(p) && TryGetProcessFilename(p) == processPath);
114120
}
115121

116122
public void TryKill(PluginInitContext context, Process p)

0 commit comments

Comments
 (0)