Skip to content

Commit 87ec1b8

Browse files
committed
Small optimizations
1 parent 290a603 commit 87ec1b8

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

Orm/Xtensive.Orm/Linq/SerializableExpressions/Internals/SerializableExpressionToExpressionConverter.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ internal sealed class SerializableExpressionToExpressionConverter
1818
{
1919
private readonly SerializableExpressionToExpressionConverter converter;
2020

21-
public void Dispose() => converter.parameterScopes.Pop();
21+
public void Dispose() => converter.parameterScopes.TryPop(out _);
2222

2323
public LambdaParameterScope(SerializableExpressionToExpressionConverter converter, Dictionary<string, ParameterExpression> currentScope)
2424
{
@@ -274,8 +274,7 @@ private ParameterExpression GetCachedParameter(Type type, string name)
274274

275275
private ParameterExpression FindParameterFast(Type type, string name)
276276
{
277-
if (parameterScopes.Count > 0) {
278-
var currentParameters = parameterScopes.Peek();
277+
if (parameterScopes.TryPeek(out var currentParameters)) {
279278
if (currentParameters.TryGetValue(name, out var replacement) && replacement.Type == type)
280279
return replacement;
281280
}
@@ -284,7 +283,7 @@ private ParameterExpression FindParameterFast(Type type, string name)
284283

285284
private ParameterExpression FindParameterSlow(Type type, string name)
286285
{
287-
foreach (var scope in parameterScopes) {
286+
foreach (var scope in parameterScopes.Skip(1)) {
288287
if (scope.TryGetValue(name, out var replacement) && replacement.Type == type)
289288
return replacement;
290289
}

0 commit comments

Comments
 (0)