Skip to content

Commit 94c5860

Browse files
author
Kapil Borle
committed
Reset command info cache only if it is null
Since, helper is a singleton that persists through multiple pssa invocation, in a given powershell session, this helps us reuse the commandinfo cache created during the first pssa invocation. Results in significant perf improvement for subsequent pssa invocations.
1 parent 889c49f commit 94c5860

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Engine/Helper.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ public void Initialize()
150150
KeywordBlockDictionary = new Dictionary<String, List<Tuple<int, int>>>(StringComparer.OrdinalIgnoreCase);
151151
VariableAnalysisDictionary = new Dictionary<Ast, VariableAnalysis>();
152152
ruleArguments = new Dictionary<string, Dictionary<string, object>>(StringComparer.OrdinalIgnoreCase);
153-
commandInfoCache = new Dictionary<string, CommandInfo>(StringComparer.OrdinalIgnoreCase);
153+
if (commandInfoCache == null)
154+
{
155+
commandInfoCache = new Dictionary<string, CommandInfo>(StringComparer.OrdinalIgnoreCase);
156+
}
154157

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

0 commit comments

Comments
 (0)