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

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Ungureanu <therzok@gmail.com>2018-03-27 20:45:46 +0300
committerMarius Ungureanu <teromario@yahoo.com>2018-04-17 14:13:26 +0300
commit67f85d7852ef1de5accdb68820d6bbd40740665a (patch)
treef953a11f5cda8fce18ac1eac8fec3c66364ce913 /main/src/core
parenteaac6d0622b43f12867d9a9e7251502f419b0b1e (diff)
[Ide] Cache environment variables at startup.
Removes the need for locking on getting the variables. Also, should reduce pressure and grab everything in one go.
Diffstat (limited to 'main/src/core')
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildEvaluationContext.cs25
1 files changed, 13 insertions, 12 deletions
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildEvaluationContext.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildEvaluationContext.cs
index 0f37e215f9..8a6cce904c 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildEvaluationContext.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildEvaluationContext.cs
@@ -44,12 +44,12 @@ namespace MonoDevelop.Projects.MSBuild
sealed class MSBuildEvaluationContext: IExpressionContext
{
Dictionary<string,string> properties = new Dictionary<string, string> (StringComparer.OrdinalIgnoreCase);
- static Dictionary<string, string> envVars = new Dictionary<string, string> ();
- readonly HashSet<string> propertiesWithTransforms = new HashSet<string> (StringComparer.OrdinalIgnoreCase);
- readonly List<string> propertiesWithTransformsSorted = new List<string> ();
+ readonly IDictionary envVars;
+ readonly HashSet<string> propertiesWithTransforms;
+ readonly List<string> propertiesWithTransformsSorted;
List<ImportSearchPathExtensionNode> searchPaths;
- public Dictionary<string, bool> ExistsEvaluationCache { get; } = new Dictionary<string, bool> ();
+ public Dictionary<string, bool> ExistsEvaluationCache { get; }
bool allResolved;
MSBuildProject project;
@@ -65,16 +65,22 @@ namespace MonoDevelop.Projects.MSBuild
public MSBuildEvaluationContext ()
{
+ ExistsEvaluationCache = new Dictionary<string, bool> ();
+ propertiesWithTransforms = new HashSet<string> (StringComparer.OrdinalIgnoreCase);
+ propertiesWithTransformsSorted = new List<string> ();
+ envVars = Environment.GetEnvironmentVariables ();
}
public MSBuildEvaluationContext (MSBuildEvaluationContext parentContext)
{
this.parentContext = parentContext;
this.project = parentContext.project;
+ this.Log = parentContext.Log;
+
+ this.ExistsEvaluationCache = parentContext.ExistsEvaluationCache;
this.propertiesWithTransforms = parentContext.propertiesWithTransforms;
this.propertiesWithTransformsSorted = parentContext.propertiesWithTransformsSorted;
- this.ExistsEvaluationCache = parentContext.ExistsEvaluationCache;
- this.Log = parentContext.Log;
+ this.envVars = parentContext.envVars;
}
internal void InitEvaluation (MSBuildProject project)
@@ -277,12 +283,7 @@ namespace MonoDevelop.Projects.MSBuild
if (parentContext != null)
return parentContext.GetPropertyValue (name);
- lock (envVars) {
- if (!envVars.TryGetValue (name, out val))
- envVars[name] = val = Environment.GetEnvironmentVariable (name);
-
- return val;
- }
+ return (string)envVars [name];
}
public string GetMetadataValue (string name)