mirror of
https://github.com/PowerShell/PowerShell.git
synced 2024-11-23 01:34:19 +08:00
Remove unnecessary Array
-> List
-> Array
conversion in ProcessBaseCommand.AllProcesses
(#15052)
This commit is contained in:
parent
49288e4289
commit
be9b14a296
@ -266,30 +266,17 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the master list of all processes.
|
||||
/// Gets an array of all processes.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
/// <value>An array of <see cref="Process"/> components that represents all the process resources.</value>
|
||||
/// <exception cref="System.Security.SecurityException">
|
||||
/// MSDN does not document the list of exceptions,
|
||||
/// but it is reasonable to expect that SecurityException is
|
||||
/// among them. Errors here will terminate the cmdlet.
|
||||
/// </exception>
|
||||
internal Process[] AllProcesses
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_allProcesses == null)
|
||||
{
|
||||
List<Process> processes = new();
|
||||
processes.AddRange(Process.GetProcesses());
|
||||
_allProcesses = processes.ToArray();
|
||||
}
|
||||
internal Process[] AllProcesses => _allProcesses ??= Process.GetProcesses();
|
||||
|
||||
return _allProcesses;
|
||||
}
|
||||
}
|
||||
|
||||
private Process[] _allProcesses = null;
|
||||
private Process[] _allProcesses;
|
||||
|
||||
/// <summary>
|
||||
/// Add <paramref name="process"/> to <see cref="_matchingProcesses"/>,
|
||||
|
Loading…
Reference in New Issue
Block a user