Skip to content

Commit caf7eb7

Browse files
authored
Update ExecutionEnvironment to cache command line
1 parent 7a81c64 commit caf7eb7

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

source/VersionHandlerImpl/src/ExecutionEnvironment.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,43 @@ namespace Google {
2525
/// </summary>
2626
internal class ExecutionEnvironment {
2727

28+
/// <summary>
29+
/// Cached lower case CommandLine
30+
/// </summary>
31+
private static string Cached_Environment_CommandLine_Lower = null;
32+
33+
/// <summary>
34+
/// Get/Set cached lower case CommandLine
35+
/// </summary>
36+
public static string Environment_CommandLine_Lower {
37+
get {
38+
if (Cached_Environment_CommandLine_Lower != null) {
39+
Cached_Environment_CommandLine_Lower = Environment.CommandLine.ToLower();
40+
}
41+
return Cached_Environment_CommandLine_Lower;
42+
}
43+
}
44+
2845
/// <summary>
2946
/// Whether the editor was started in batch mode.
3047
/// </summary>
3148
public static bool InBatchMode {
32-
get { return Environment.CommandLine.ToLower().Contains("-batchmode"); }
49+
get { return Environment_CommandLine_Lower.Contains("-batchmode"); }
3350
}
3451

3552
/// <summary>
3653
/// Whether the editor was started with a method to executed.
3754
/// </summary>
3855
public static bool ExecuteMethodEnabled {
39-
get { return Environment.CommandLine.ToLower().Contains("-executemethod"); }
56+
get { return Environment_CommandLine_Lower.Contains("-executemethod"); }
4057
}
4158

4259
/// <summary>
4360
/// Whether the UI should be treated as interactive.
4461
/// </summary>
4562
internal static bool InteractiveMode {
4663
get {
47-
return !(Environment.CommandLine.ToLower().Contains("-gvh_noninteractive") ||
64+
return !(Environment_CommandLine_Lower.Contains("-gvh_noninteractive") ||
4865
ExecutionEnvironment.InBatchMode);
4966
}
5067
}

0 commit comments

Comments
 (0)