Add optimization in GetHashCode for Int16 and SByte (#21652)
authorichensky <IChensky@live.com>
Sun, 23 Dec 2018 12:47:25 +0000 (14:47 +0200)
committerJan Kotas <jkotas@microsoft.com>
Sun, 23 Dec 2018 12:47:25 +0000 (04:47 -0800)
src/System.Private.CoreLib/shared/System/Int16.cs
src/System.Private.CoreLib/shared/System/SByte.cs

index bb5a91b..37e1639 100644 (file)
@@ -63,7 +63,7 @@ namespace System
         // Returns a HashCode for the Int16
         public override int GetHashCode()
         {
-            return ((int)((ushort)m_value) | (((int)m_value) << 16));
+            return m_value;
         }
 
 
index c3bc386..0ebe882 100644 (file)
@@ -66,7 +66,7 @@ namespace System
         // Gets a hash code for this instance.
         public override int GetHashCode()
         {
-            return ((int)m_value ^ (int)m_value << 8);
+            return m_value;
         }