From aece15768033c95f90d84d111b490085269e188d Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Mon, 29 Mar 2021 18:10:00 -0400 Subject: [PATCH] Remove unnecessary delegate/closure from NtProcessInfoHelper on Windows (#50387) --- .../src/System/Diagnostics/ProcessManager.Win32.cs | 6 +++--- .../src/System/Diagnostics/ProcessManager.Windows.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Win32.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Win32.cs index 18243a7..53c9c74 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Win32.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Win32.cs @@ -252,7 +252,7 @@ namespace System.Diagnostics private const int DefaultCachedBufferSize = 128 * 1024; #endif - internal static ProcessInfo[] GetProcessInfos(Predicate? processIdFilter = null) + internal static ProcessInfo[] GetProcessInfos(int? processIdFilter = null) { ProcessInfo[] processInfos; @@ -342,7 +342,7 @@ namespace System.Diagnostics return newSize; } - private static unsafe ProcessInfo[] GetProcessInfos(ReadOnlySpan data, Predicate? processIdFilter) + private static unsafe ProcessInfo[] GetProcessInfos(ReadOnlySpan data, int? processIdFilter) { // Use a dictionary to avoid duplicate entries if any // 60 is a reasonable number for processes on a normal machine. @@ -356,7 +356,7 @@ namespace System.Diagnostics // Process ID shouldn't overflow. OS API GetCurrentProcessID returns DWORD. int processInfoProcessId = pi.UniqueProcessId.ToInt32(); - if (processIdFilter == null || processIdFilter(processInfoProcessId)) + if (processIdFilter == null || processIdFilter.GetValueOrDefault() == processInfoProcessId) { // get information for a process ProcessInfo processInfo = new ProcessInfo((int)pi.NumberOfThreads) diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Windows.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Windows.cs index 9807516..103443d 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Windows.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Windows.cs @@ -75,7 +75,7 @@ namespace System.Diagnostics else { // local case: do not use performance counter and also attempt to get the matching (by pid) process only - ProcessInfo[] processInfos = NtProcessInfoHelper.GetProcessInfos(pid => pid == processId); + ProcessInfo[] processInfos = NtProcessInfoHelper.GetProcessInfos(processId); if (processInfos.Length == 1) { return processInfos[0]; -- 2.7.4