File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- using System ;
1+ // <copyright file="Bits.cs" company="Sedat Kapanoglu">
2+ // Copyright (c) 2014-2025 Sedat Kapanoglu
3+ // Licensed under Apache-2.0 License (see LICENSE.txt file for details)
4+ // </copyright>
5+
6+ using System ;
27
38namespace SimpleBase
49{
@@ -36,25 +41,5 @@ internal static ulong PartialBigEndianBytesToUInt64(ReadOnlySpan<byte> bytes)
3641 }
3742 return result ;
3843 }
39-
40- /// <summary>
41- /// Converts a UInt64 to a byte array in big-endian order.
42- /// </summary>
43- /// <param name="value">Value to convert.</param>
44- /// <param name="output">Output buffer.</param>
45- /// <exception cref="ArgumentException">If the buffer is too small.</exception>
46- internal static void UInt64ToBigEndianBytes ( ulong value , Span < byte > output )
47- {
48- if ( output . Length < sizeof ( ulong ) )
49- {
50- throw new ArgumentException ( "Output is too small" , nameof ( output ) ) ;
51- }
52- int byteCount = sizeof ( ulong ) ;
53- for ( int i = byteCount - 1 ; i >= 0 ; i -- )
54- {
55- output [ i ] = ( byte ) ( value & 0xFF ) ;
56- value >>= 8 ;
57- }
58- }
5944 }
6045}
Original file line number Diff line number Diff line change 44// </copyright>
55
66using System ;
7+ using System . Buffers . Binary ;
78
89namespace SimpleBase ;
910
@@ -212,7 +213,7 @@ enum DecodeResult
212213 }
213214 pad += ( uint ) value ;
214215 }
215- Bits . UInt64ToBigEndianBytes ( pad , output ) ;
216+ BinaryPrimitives . WriteUInt64BigEndian ( output , pad ) ;
216217 return ( DecodeResult . Success , null ) ;
217218 }
218219
You can’t perform that action at this time.
0 commit comments