Applying PR feedback
authorPhil Garcia <phil@thinkedge.com>
Wed, 27 Jun 2018 05:03:49 +0000 (22:03 -0700)
committerPhil Garcia <phil@thinkedge.com>
Wed, 27 Jun 2018 05:03:49 +0000 (22:03 -0700)
src/System.Private.CoreLib/shared/Internal/Runtime/CompilerServices/Unsafe.cs
src/System.Private.CoreLib/shared/System/Double.cs
src/System.Private.CoreLib/shared/System/Single.cs

index aeff3ce..03d3f85 100644 (file)
@@ -358,6 +358,17 @@ namespace Internal.Runtime.CompilerServices
         }
 
         /// <summary>
+        /// Reinterprets the given location as a reference to a value of type <typeparamref name="T"/>.
+        /// </summary>
+        [Intrinsic]
+        [NonVersionable]
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        public static ref T AsRef<T>(in T source)
+        {
+            throw new PlatformNotSupportedException();
+        }
+
+        /// <summary>
         /// Determines the byte offset from origin to target from the given references.
         /// </summary>
         [Intrinsic]
index 308dda5..69da2e3 100644 (file)
@@ -226,7 +226,7 @@ namespace System
         [MethodImpl(MethodImplOptions.AggressiveInlining)] // 64-bit constants make the IL unusually large that makes the inliner to reject the method
         public override int GetHashCode()
         {
-            var bits = BitConverter.DoubleToInt64Bits(m_value);
+            var bits = Unsafe.As<double, long>(ref Unsafe.AsRef(in m_value));
 
             // Optimized check for IsNan() || IsZero()
             if (((bits - 1) & 0x7FFFFFFFFFFFFFFF) >= 0x7FF0000000000000)
index d62ff9c..7dddb02 100644 (file)
@@ -217,7 +217,7 @@ namespace System
 
         public override int GetHashCode()
         {
-            var bits = BitConverter.SingleToInt32Bits(m_value);
+            var bits = Unsafe.As<float, int>(ref Unsafe.AsRef(in m_value));
 
             // Optimized check for IsNan() || IsZero()
             if (((bits - 1) & 0x7FFFFFFF) >= 0x7F800000)