11using System ;
22using System . IO ;
3+ using System . Security ;
34using UnityEngine ;
45using static MLAPI . NetworkingManagerComponents . Binary . Arithmetic ;
56
@@ -300,13 +301,9 @@ public void WriteSingle(float value)
300301 /// <param name="value">Value to write</param>
301302 public void WriteDouble ( double value )
302303 {
303- lock ( holder_d )
304- lock ( holder_l )
305- {
306- holder_d [ 0 ] = value ;
307- Buffer . BlockCopy ( holder_d , 0 , holder_l , 0 , 8 ) ;
308- WriteUInt64 ( holder_l [ 0 ] ) ;
309- }
304+ long binary = BitConverter . DoubleToInt64Bits ( value ) ;
305+ WriteInt64 ( binary ) ;
306+
310307 }
311308
312309 /// <summary>
@@ -330,13 +327,8 @@ public void WriteSinglePacked(float value)
330327 /// <param name="value">Value to write</param>
331328 public void WriteDoublePacked ( double value )
332329 {
333- lock ( holder_d )
334- lock ( holder_l )
335- {
336- holder_d [ 0 ] = value ;
337- Buffer . BlockCopy ( holder_d , 0 , holder_l , 0 , 8 ) ;
338- WriteUInt64Packed ( BinaryHelpers . SwapEndian ( holder_l [ 0 ] ) ) ;
339- }
330+ long binary = BitConverter . DoubleToInt64Bits ( value ) ;
331+ WriteInt64Packed ( binary ) ;
340332 }
341333
342334 /// <summary>
@@ -532,14 +524,9 @@ public float ReadSingle()
532524 /// <returns>The read value</returns>
533525 public double ReadDouble ( )
534526 {
535- ulong read = ReadUInt64 ( ) ;
536- lock ( holder_d )
537- lock ( holder_l )
538- {
539- holder_l [ 0 ] = read ;
540- Buffer . BlockCopy ( holder_l , 0 , holder_d , 0 , 8 ) ;
541- return holder_d [ 0 ] ;
542- }
527+
528+ long read = ReadInt64 ( ) ;
529+ return BitConverter . Int64BitsToDouble ( read ) ;
543530 }
544531
545532 /// <summary>
@@ -564,14 +551,8 @@ public float ReadSinglePacked()
564551 /// <returns>The read value</returns>
565552 public double ReadDoublePacked ( )
566553 {
567- ulong read = ReadUInt64Packed ( ) ;
568- lock ( holder_d )
569- lock ( holder_l )
570- {
571- holder_l [ 0 ] = BinaryHelpers . SwapEndian ( read ) ;
572- Buffer . BlockCopy ( holder_l , 0 , holder_d , 0 , 8 ) ;
573- return holder_d [ 0 ] ;
574- }
554+ long read = ReadInt64Packed ( ) ;
555+ return BitConverter . Int64BitsToDouble ( read ) ;
575556 }
576557
577558 /// <summary>
0 commit comments