mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
C#: Address review comment: Make dictionary type more specific.
This commit is contained in:
@@ -163,8 +163,9 @@ namespace Semmle.Extraction
|
||||
where Entity : ICachedEntity
|
||||
=> CreateNonNullEntity(factory, init, objectEntityCache);
|
||||
|
||||
|
||||
private Entity CreateNonNullEntity<Type, Entity>(ICachedEntityFactory<Type, Entity> factory, Type init, IDictionary<object, ICachedEntity> dictionary) where Entity : ICachedEntity
|
||||
private Entity CreateNonNullEntity<Type, Src, Entity>(ICachedEntityFactory<Type, Entity> factory, Type init, IDictionary<Src, ICachedEntity> dictionary)
|
||||
where Entity : ICachedEntity
|
||||
where Type : Src
|
||||
{
|
||||
if (init is null) throw new ArgumentException("Unexpected null value", nameof(init));
|
||||
|
||||
@@ -231,17 +232,9 @@ namespace Semmle.Extraction
|
||||
#if DEBUG_LABELS
|
||||
readonly Dictionary<string, ICachedEntity> idLabelCache = new Dictionary<string, ICachedEntity>();
|
||||
#endif
|
||||
class SymbolComparer : IEqualityComparer<object>
|
||||
{
|
||||
IEqualityComparer<ISymbol> comparer = SymbolEqualityComparer.IncludeNullability;
|
||||
|
||||
bool IEqualityComparer<object>.Equals(object x, object y) => comparer.Equals((ISymbol)x, (ISymbol)y);
|
||||
|
||||
int IEqualityComparer<object>.GetHashCode(object obj) => comparer.GetHashCode((ISymbol)obj);
|
||||
}
|
||||
|
||||
readonly IDictionary<object, ICachedEntity> objectEntityCache = new Dictionary<object, ICachedEntity>();
|
||||
readonly IDictionary<object, ICachedEntity> symbolEntityCache = new Dictionary<object, ICachedEntity>(10000, new SymbolComparer());
|
||||
readonly IDictionary<ISymbol, ICachedEntity> symbolEntityCache = new Dictionary<ISymbol, ICachedEntity>(10000, SymbolEqualityComparer.IncludeNullability);
|
||||
readonly Dictionary<ICachedEntity, Label> entityLabelCache = new Dictionary<ICachedEntity, Label>();
|
||||
readonly HashSet<Label> extractedGenerics = new HashSet<Label>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user