Skip to content

Commit c23d0ae

Browse files
author
Kapil Borle
authored
Merge pull request #695 from PowerShell/kapilmb/FixPerformance
Reuse command info cache during a PS session
2 parents c7fa7e1 + 94c5860 commit c23d0ae

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Engine/Helper.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ internal set
6565
{
6666
lock (syncRoot)
6767
{
68-
instance = value;
68+
if (instance == null)
69+
{
70+
instance = value;
71+
}
6972
}
7073
}
7174
}
@@ -147,7 +150,10 @@ public void Initialize()
147150
KeywordBlockDictionary = new Dictionary<String, List<Tuple<int, int>>>(StringComparer.OrdinalIgnoreCase);
148151
VariableAnalysisDictionary = new Dictionary<Ast, VariableAnalysis>();
149152
ruleArguments = new Dictionary<string, Dictionary<string, object>>(StringComparer.OrdinalIgnoreCase);
150-
commandInfoCache = new Dictionary<string, CommandInfo>(StringComparer.OrdinalIgnoreCase);
153+
if (commandInfoCache == null)
154+
{
155+
commandInfoCache = new Dictionary<string, CommandInfo>(StringComparer.OrdinalIgnoreCase);
156+
}
151157

152158
IEnumerable<CommandInfo> aliases = this.invokeCommand.GetCommands("*", CommandTypes.Alias, true);
153159

0 commit comments

Comments
 (0)