Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZoltan Varga <vargaz@gmail.com>2017-10-24 01:32:31 +0300
committerAlexander Köplinger <alex.koeplinger@outlook.com>2017-10-24 01:32:31 +0300
commit03ea90cf1f9a823abf7f0fb23edbcfee6b640f82 (patch)
treee8a160731c4eca7a6e15e0940079b48da39c561d /mcs/class/System
parent77b4cd11d1d7c7b79c426ddc5a343b373a3b2cc3 (diff)
[bcl] Optimize Process.GetCurrentProcess ().MainModule. (#5843)
Diffstat (limited to 'mcs/class/System')
-rw-r--r--mcs/class/System/System.Diagnostics/Process.cs11
1 files changed, 10 insertions, 1 deletions
diff --git a/mcs/class/System/System.Diagnostics/Process.cs b/mcs/class/System/System.Diagnostics/Process.cs
index b038095093c..35b7f3fac65 100644
--- a/mcs/class/System/System.Diagnostics/Process.cs
+++ b/mcs/class/System/System.Diagnostics/Process.cs
@@ -72,6 +72,8 @@ namespace System.Diagnostics
string process_name;
+ static ProcessModule current_main_module;
+
/* Private constructor called from other methods */
private Process (SafeProcessHandle handle, int id) {
SetProcessHandle (handle);
@@ -98,7 +100,14 @@ namespace System.Diagnostics
[MonitoringDescription ("The main module of the process.")]
public ProcessModule MainModule {
get {
- return(this.Modules[0]);
+ /* Optimize Process.GetCurrentProcess ().MainModule */
+ if (processId == NativeMethods.GetCurrentProcessId ()) {
+ if (current_main_module == null)
+ current_main_module = this.Modules [0];
+ return current_main_module;
+ } else {
+ return this.Modules [0];
+ }
}
}