diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs index a1fc75f100bdba..b6978f31544690 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs @@ -308,14 +308,11 @@ public unsafe Type GetOrLoadType() [RequiresUnreferencedCode("Lazy TypeMap isn't supported for Trimmer scenarios")] private sealed class LazyExternalTypeDictionary : LazyTypeLoadDictionary { - private static int ComputeHashCode(string key) => key.GetHashCode(); - - private readonly Dictionary _lazyData = new(); + private readonly Dictionary _lazyData = new(); protected override bool TryGetOrLoadType(string key, [NotNullWhen(true)] out Type? type) { - int hash = ComputeHashCode(key); - if (!_lazyData.TryGetValue(hash, out DelayedType? value)) + if (!_lazyData.TryGetValue(key, out DelayedType? value)) { type = null; return false; @@ -327,13 +324,12 @@ protected override bool TryGetOrLoadType(string key, [NotNullWhen(true)] out Typ public void Add(string key, TypeNameUtf8 targetType, RuntimeAssembly fallbackAssembly) { - int hash = ComputeHashCode(key); - if (_lazyData.ContainsKey(hash)) + if (_lazyData.ContainsKey(key)) { ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException(key); } - _lazyData.Add(hash, new DelayedType(targetType, fallbackAssembly)); + _lazyData.Add(key, new DelayedType(targetType, fallbackAssembly)); } }