@@ -391,6 +391,31 @@ internal static byte[] UInt16_To_LE(ushort n)
391
391
return bs ;
392
392
}
393
393
394
+ internal static byte [ ] UInt16_To_LE ( ushort [ ] ns )
395
+ {
396
+ byte [ ] bs = new byte [ 2 * ns . Length ] ;
397
+ UInt16_To_LE ( ns , bs , 0 ) ;
398
+ return bs ;
399
+ }
400
+
401
+ internal static void UInt16_To_LE ( ushort [ ] ns , byte [ ] bs , int off )
402
+ {
403
+ for ( int i = 0 ; i < ns . Length ; ++ i )
404
+ {
405
+ UInt16_To_LE ( ns [ i ] , bs , off ) ;
406
+ off += 2 ;
407
+ }
408
+ }
409
+
410
+ internal static void UInt16_To_LE ( ushort [ ] ns , int nsOff , int nsLen , byte [ ] bs , int bsOff )
411
+ {
412
+ for ( int i = 0 ; i < nsLen ; ++ i )
413
+ {
414
+ UInt16_To_LE ( ns [ nsOff + i ] , bs , bsOff ) ;
415
+ bsOff += 2 ;
416
+ }
417
+ }
418
+
394
419
internal static ushort LE_To_UInt16 ( byte [ ] bs )
395
420
{
396
421
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
@@ -413,6 +438,31 @@ internal static ushort LE_To_UInt16(byte[] bs, int off)
413
438
#endif
414
439
}
415
440
441
+ internal static void LE_To_UInt16 ( byte [ ] bs , int off , ushort [ ] ns )
442
+ {
443
+ for ( int i = 0 ; i < ns . Length ; ++ i )
444
+ {
445
+ ns [ i ] = LE_To_UInt16 ( bs , off ) ;
446
+ off += 2 ;
447
+ }
448
+ }
449
+
450
+ internal static void LE_To_UInt16 ( byte [ ] bs , int bOff , ushort [ ] ns , int nOff , int count )
451
+ {
452
+ for ( int i = 0 ; i < count ; ++ i )
453
+ {
454
+ ns [ nOff + i ] = LE_To_UInt16 ( bs , bOff ) ;
455
+ bOff += 2 ;
456
+ }
457
+ }
458
+
459
+ internal static ushort [ ] LE_To_UInt16 ( byte [ ] bs , int off , int count )
460
+ {
461
+ ushort [ ] ns = new ushort [ count ] ;
462
+ LE_To_UInt16 ( bs , off , ns ) ;
463
+ return ns ;
464
+ }
465
+
416
466
internal static byte [ ] UInt32_To_LE ( uint n )
417
467
{
418
468
byte [ ] bs = new byte [ 4 ] ;
@@ -521,11 +571,7 @@ internal static void LE_To_UInt32(byte[] bs, int bOff, uint[] ns, int nOff, int
521
571
internal static uint [ ] LE_To_UInt32 ( byte [ ] bs , int off , int count )
522
572
{
523
573
uint [ ] ns = new uint [ count ] ;
524
- for ( int i = 0 ; i < ns . Length ; ++ i )
525
- {
526
- ns [ i ] = LE_To_UInt32 ( bs , off ) ;
527
- off += 4 ;
528
- }
574
+ LE_To_UInt32 ( bs , off , ns ) ;
529
575
return ns ;
530
576
}
531
577
@@ -621,6 +667,13 @@ internal static void LE_To_UInt64(byte[] bs, int bsOff, ulong[] ns, int nsOff, i
621
667
}
622
668
}
623
669
670
+ internal static ulong [ ] LE_To_UInt64 ( byte [ ] bs , int off , int count )
671
+ {
672
+ ulong [ ] ns = new ulong [ count ] ;
673
+ LE_To_UInt64 ( bs , off , ns ) ;
674
+ return ns ;
675
+ }
676
+
624
677
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
625
678
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
626
679
internal static uint BE_To_UInt32 ( ReadOnlySpan < byte > bs )
@@ -700,6 +753,16 @@ internal static ushort LE_To_UInt16(ReadOnlySpan<byte> bs)
700
753
return BinaryPrimitives . ReadUInt16LittleEndian ( bs ) ;
701
754
}
702
755
756
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
757
+ internal static void LE_To_UInt16 ( ReadOnlySpan < byte > bs , Span < ushort > ns )
758
+ {
759
+ for ( int i = 0 ; i < ns . Length ; ++ i )
760
+ {
761
+ ns [ i ] = LE_To_UInt16 ( bs ) ;
762
+ bs = bs [ 2 ..] ;
763
+ }
764
+ }
765
+
703
766
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
704
767
internal static uint LE_To_UInt32 ( ReadOnlySpan < byte > bs )
705
768
{
@@ -738,12 +801,32 @@ internal static void UInt16_To_BE(ushort n, Span<byte> bs)
738
801
BinaryPrimitives . WriteUInt16BigEndian ( bs , n ) ;
739
802
}
740
803
804
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
805
+ internal static void UInt16_To_BE ( ReadOnlySpan < ushort > ns , Span < byte > bs )
806
+ {
807
+ for ( int i = 0 ; i < ns . Length ; ++ i )
808
+ {
809
+ UInt16_To_BE ( ns [ i ] , bs ) ;
810
+ bs = bs [ 2 ..] ;
811
+ }
812
+ }
813
+
741
814
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
742
815
internal static void UInt16_To_LE ( ushort n , Span < byte > bs )
743
816
{
744
817
BinaryPrimitives . WriteUInt16LittleEndian ( bs , n ) ;
745
818
}
746
819
820
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
821
+ internal static void UInt16_To_LE ( ReadOnlySpan < ushort > ns , Span < byte > bs )
822
+ {
823
+ for ( int i = 0 ; i < ns . Length ; ++ i )
824
+ {
825
+ UInt16_To_LE ( ns [ i ] , bs ) ;
826
+ bs = bs [ 2 ..] ;
827
+ }
828
+ }
829
+
747
830
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
748
831
internal static void UInt32_To_BE ( uint n , Span < byte > bs )
749
832
{
0 commit comments