Skip to content

Commit 1707ec7

Browse files
committed
ProcessKiller: quick refactoring
1 parent 852750d commit 1707ec7

File tree

1 file changed

+10
-16
lines changed
  • Plugins/Flow.Launcher.Plugin.ProcessKiller

1 file changed

+10
-16
lines changed

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

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private List<Result> CreateResultsFromProcesses(List<ProcessResult> processlist,
6868
results.Insert(0, new Result()
6969
{
7070
IcoPath = "Images\\app.png",
71-
Title = "kill all \"" + termToSearch + "\" process",
71+
Title = "kill all \"" + termToSearch + "\" processes",
7272
SubTitle = "",
7373
Score = 200,
7474
Action = (c) =>
@@ -96,29 +96,25 @@ void KillProcess(Process p)
9696
}
9797
catch (Exception e)
9898
{
99-
Log.Exception($"Fail to kill process {p.ProcessName}", e);
99+
Log.Exception($"|ProcessKiller.CreateResultsFromProcesses|Failed to kill process {p.ProcessName}", e);
100100
}
101101
}
102102
}
103103
private List<ProcessResult> GetProcesslist(string termToSearch)
104104
{
105105
var processlist = new List<ProcessResult>();
106-
var processes = Process.GetProcesses();
107-
if (string.IsNullOrWhiteSpace(termToSearch))
106+
107+
foreach (var p in Process.GetProcesses())
108108
{
109-
// show all process
110-
foreach (var p in processes)
111-
{
112-
if (FilterSystemProcesses(p)) continue;
109+
if (FilterSystemProcesses(p)) continue;
113110

111+
if (string.IsNullOrWhiteSpace(termToSearch))
112+
{
113+
// show all non-system processes
114114
processlist.Add(new ProcessResult(p,0));
115115
}
116-
}
117-
else
118-
{
119-
foreach (var p in processes)
116+
else
120117
{
121-
if (FilterSystemProcesses(p)) continue;
122118
var score = StringMatcher.FuzzySearch(termToSearch, p.ProcessName + p.Id).Score;
123119
if (score > 0)
124120
{
@@ -132,9 +128,7 @@ private List<ProcessResult> GetProcesslist(string termToSearch)
132128
bool FilterSystemProcesses(Process p)
133129
{
134130
var name = p.ProcessName.ToLower();
135-
if (_systemProcessList.Contains(name))
136-
return true;
137-
return false;
131+
return _systemProcessList.Contains(name);
138132
}
139133
}
140134

0 commit comments

Comments
 (0)