1
1
using System ;
2
2
using System . IO ;
3
+ using System . Security ;
3
4
using UnityEngine ;
4
5
using static MLAPI . NetworkingManagerComponents . Binary . Arithmetic ;
5
6
@@ -300,13 +301,9 @@ public void WriteSingle(float value)
300
301
/// <param name="value">Value to write</param>
301
302
public void WriteDouble ( double value )
302
303
{
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
+
310
307
}
311
308
312
309
/// <summary>
@@ -330,13 +327,8 @@ public void WriteSinglePacked(float value)
330
327
/// <param name="value">Value to write</param>
331
328
public void WriteDoublePacked ( double value )
332
329
{
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 ) ;
340
332
}
341
333
342
334
/// <summary>
@@ -532,14 +524,9 @@ public float ReadSingle()
532
524
/// <returns>The read value</returns>
533
525
public double ReadDouble ( )
534
526
{
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 ) ;
543
530
}
544
531
545
532
/// <summary>
@@ -564,14 +551,8 @@ public float ReadSinglePacked()
564
551
/// <returns>The read value</returns>
565
552
public double ReadDoublePacked ( )
566
553
{
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 ) ;
575
556
}
576
557
577
558
/// <summary>
0 commit comments