提交 67fe11ba 编写于 作者: C CyrusNajmabadi 提交者: Jason Malinowski

Don't allocate a lambda each time we get a hashcode for a named type.

上级 569d0016
......@@ -19,6 +19,7 @@ private class GetHashCodeVisitor
private readonly bool _objectAndDynamicCompareEqually;
private readonly Func<int, IParameterSymbol, int> _parameterAggregator;
private readonly Func<int, ISymbol, int> _symbolAggregator;
private readonly Func<int, INamedTypeSymbol, int> _namedTypeAggregator;
public GetHashCodeVisitor(
SymbolEquivalenceComparer symbolEquivalenceComparer,
......@@ -30,6 +31,7 @@ private class GetHashCodeVisitor
_objectAndDynamicCompareEqually = objectAndDynamicCompareEqually;
_parameterAggregator = (acc, sym) => Hash.Combine(symbolEquivalenceComparer.ParameterEquivalenceComparer.GetHashCode(sym), acc);
_symbolAggregator = (acc, sym) => GetHashCode(sym, acc);
_namedTypeAggregator = CombineNamedTypeHashCode;
}
public int GetHashCode(ISymbol x, int currentHash)
......@@ -169,10 +171,10 @@ private int CombineHashCodes(IModuleSymbol x, int currentHash)
private int CombineHashCodes(INamedTypeSymbol x, int currentHash)
{
return Unwrap(x).Aggregate(currentHash, (a, n) => CombineNamedTypeHashCode(n, a));
return Unwrap(x).Aggregate(currentHash, _namedTypeAggregator);
}
private int CombineNamedTypeHashCode(INamedTypeSymbol x, int currentHash)
private int CombineNamedTypeHashCode(int currentHash, INamedTypeSymbol x)
{
// If we want object and dynamic to be the same, and this is 'object', then return
// the same hash we do for 'dynamic'.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册