Skip to content

Commit 6a76211

Browse files
committed
remove redundant Bits.UInt64ToBigEndianBytes()
1 parent 9492242 commit 6a76211

File tree

2 files changed

+8
-22
lines changed

2 files changed

+8
-22
lines changed

src/Bits.cs

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
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

38
namespace 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
}

src/MoneroBase58.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// </copyright>
55

66
using System;
7+
using System.Buffers.Binary;
78

89
namespace 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

0 commit comments

Comments
 (0)