Skip to content

Commit

Permalink
Don't visit the same argument nodes twice
Browse files Browse the repository at this point in the history
  • Loading branch information
stakx committed Apr 18, 2020
1 parent 5234fb2 commit 0811524
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected override Expression VisitMethodCall(MethodCallExpression node)
var indexer = node.Method.DeclaringType.GetProperty(name, node.Method.ReturnType, argumentTypes);
Debug.Assert(indexer != null && indexer.GetGetMethod(true) == node.Method);

return Expression.MakeIndex(instance, indexer, this.Visit(arguments));
return Expression.MakeIndex(instance, indexer, arguments);
}
}
else if (node.Method.IsSetAccessor())
Expand All @@ -78,7 +78,7 @@ protected override Expression VisitMethodCall(MethodCallExpression node)
Debug.Assert(property != null && property.GetSetMethod(true) == node.Method);

var value = node.Arguments[0];
return Expression.Assign(Expression.MakeMemberAccess(instance, property), this.Visit(value));
return Expression.Assign(Expression.MakeMemberAccess(instance, property), value);
}
else
{
Expand All @@ -88,9 +88,9 @@ protected override Expression VisitMethodCall(MethodCallExpression node)
var indexer = node.Method.DeclaringType.GetProperty(name, parameterTypes.Last(), argumentTypes);
Debug.Assert(indexer != null && indexer.GetSetMethod(true) == node.Method);

var indices = new ReadOnlyCollection<Expression>(arguments.Take(argumentCount - 1).ToList());
var indices = arguments.Take(argumentCount - 1);
var value = arguments.Last();
return Expression.Assign(Expression.MakeIndex(instance, indexer, this.Visit(indices)), this.Visit(value));
return Expression.Assign(Expression.MakeIndex(instance, indexer, indices), value);
}
}
}
Expand Down

0 comments on commit 0811524

Please sign in to comment.