Skip to content

Commit d6146f4

Browse files
author
Sébastien Geiser
committed
Some perfs improvement load Assemblies statically by default.
+ Some renaming to be clearier.
1 parent 616548d commit d6146f4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

CodingSeb.ExpressionEvaluator/ExpressionEvaluator.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,8 @@ public static void ClearAllCaches()
452452

453453
#region Assemblies, Namespaces and types lists
454454

455+
private static readonly IList<Assembly> assemblies = AppDomain.CurrentDomain.GetAssemblies().ToList();
456+
455457
/// <summary>
456458
/// All assemblies needed to resolves Types
457459
/// by default all Assemblies loaded in the current AppDomain
@@ -866,7 +868,7 @@ public ExpressionEvaluator(IDictionary<string, object> variables) : this()
866868

867869
protected virtual void AssembliesInit()
868870
{
869-
Assemblies = AppDomain.CurrentDomain.GetAssemblies().ToList();
871+
Assemblies = assemblies;
870872
}
871873

872874
protected virtual void DefaultDecimalSeparatorInit()
@@ -1419,7 +1421,7 @@ public object Evaluate(string expression)
14191421

14201422
for (int i = 0; i < expression.Length; i++)
14211423
{
1422-
if (!ParsingMethods.Any(m => m(expression, stack, ref i)))
1424+
if (!ParsingMethods.Any(parsingMethod => parsingMethod(expression, stack, ref i)))
14231425
{
14241426
string s = expression.Substring(i, 1);
14251427

0 commit comments

Comments
 (0)