@@ -60,7 +60,9 @@ public Entity CreateEntity<Type, Entity>(ICachedEntityFactory<Type, Entity> fact
60
60
/// <param name="factory">The entity factory.</param>
61
61
/// <param name="init">The initializer for the entity.</param>
62
62
/// <returns>The new/existing entity.</returns>
63
- public Entity CreateEntityFromSymbol < Type , Entity > ( ICachedEntityFactory < Type , Entity > factory , Type init ) where Entity : ICachedEntity
63
+ public Entity CreateEntityFromSymbol < Type , Entity > ( ICachedEntityFactory < Type , Entity > factory , Type init )
64
+ where Entity : ICachedEntity
65
+ where Type : ISymbol
64
66
{
65
67
return init == null ? CreateEntity2 ( factory , init ) : CreateNonNullEntity ( factory , init , symbolEntityCache ) ;
66
68
}
@@ -149,8 +151,9 @@ private void CheckEntityHasUniqueLabel(string id, ICachedEntity entity)
149
151
private Entity CreateNonNullEntity < Type , Entity > ( ICachedEntityFactory < Type , Entity > factory , Type init ) where Entity : ICachedEntity
150
152
=> CreateNonNullEntity ( factory , init , objectEntityCache ) ;
151
153
152
-
153
- private Entity CreateNonNullEntity < Type , Entity > ( ICachedEntityFactory < Type , Entity > factory , Type init , IDictionary < object , ICachedEntity > dictionary ) where Entity : ICachedEntity
154
+ private Entity CreateNonNullEntity < Type , Src , Entity > ( ICachedEntityFactory < Type , Entity > factory , Type init , IDictionary < Src , ICachedEntity > dictionary )
155
+ where Entity : ICachedEntity
156
+ where Type : Src
154
157
{
155
158
if ( dictionary . TryGetValue ( init , out var cached ) )
156
159
return ( Entity ) cached ;
@@ -215,17 +218,9 @@ public void AddFreshLabel(IEntity entity)
215
218
#if DEBUG_LABELS
216
219
readonly Dictionary < string , ICachedEntity > idLabelCache = new Dictionary < string , ICachedEntity > ( ) ;
217
220
#endif
218
- class SymbolComparer : IEqualityComparer < object >
219
- {
220
- IEqualityComparer < ISymbol > comparer = SymbolEqualityComparer . IncludeNullability ;
221
-
222
- bool IEqualityComparer < object > . Equals ( object x , object y ) => comparer . Equals ( ( ISymbol ) x , ( ISymbol ) y ) ;
223
-
224
- int IEqualityComparer < object > . GetHashCode ( object obj ) => comparer . GetHashCode ( ( ISymbol ) obj ) ;
225
- }
226
221
227
222
readonly IDictionary < object , ICachedEntity > objectEntityCache = new Dictionary < object , ICachedEntity > ( ) ;
228
- readonly IDictionary < object , ICachedEntity > symbolEntityCache = new Dictionary < object , ICachedEntity > ( 10000 , new SymbolComparer ( ) ) ;
223
+ readonly IDictionary < ISymbol , ICachedEntity > symbolEntityCache = new Dictionary < ISymbol , ICachedEntity > ( 10000 , SymbolEqualityComparer . IncludeNullability ) ;
229
224
readonly Dictionary < ICachedEntity , Label > entityLabelCache = new Dictionary < ICachedEntity , Label > ( ) ;
230
225
readonly HashSet < Label > extractedGenerics = new HashSet < Label > ( ) ;
231
226
0 commit comments