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>
|
/// <summary>
|
||||||
/// Retrieve the master list of all processes.
|
/// Gets an array of all processes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
/// <value>An array of <see cref="Process"/> components that represents all the process resources.</value>
|
||||||
/// <exception cref="System.Security.SecurityException">
|
/// <exception cref="System.Security.SecurityException">
|
||||||
/// MSDN does not document the list of exceptions,
|
/// MSDN does not document the list of exceptions,
|
||||||
/// but it is reasonable to expect that SecurityException is
|
/// but it is reasonable to expect that SecurityException is
|
||||||
/// among them. Errors here will terminate the cmdlet.
|
/// among them. Errors here will terminate the cmdlet.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
internal Process[] AllProcesses
|
internal Process[] AllProcesses => _allProcesses ??= Process.GetProcesses();
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_allProcesses == null)
|
|
||||||
{
|
|
||||||
List<Process> processes = new();
|
|
||||||
processes.AddRange(Process.GetProcesses());
|
|
||||||
_allProcesses = processes.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
return _allProcesses;
|
private Process[] _allProcesses;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Process[] _allProcesses = null;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add <paramref name="process"/> to <see cref="_matchingProcesses"/>,
|
/// Add <paramref name="process"/> to <see cref="_matchingProcesses"/>,
|
||||||
|
|
Loading…
Reference in a new issue