Skip to content

Commit 0a16c76

Browse files
authored
Fix debug asserts and docs for VIntUtils, apache#1279 (apache#1360)
1 parent a6f4657 commit 0a16c76

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/Lucene.Net/Support/VIntUtils.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ internal static class VIntUtils
4343

4444
/// <summary>
4545
/// Tries to read a 32-bit VInt from the given <paramref name="source"/>.
46-
/// <paramref name="source"/> must be at least <see cref="MaxVInt32Length"/> bytes
47-
/// in length to avoid possible out-of-range exceptions.
46+
/// <paramref name="source"/> must be at least 1 byte in length, and be well-formed if multibyte,
47+
/// to avoid possible out-of-range exceptions.
4848
/// </summary>
4949
/// <param name="source">The source bytes to read from.</param>
5050
/// <param name="value">The decoded value (undefined if the method returns <c>false</c>).</param>
@@ -55,7 +55,7 @@ internal static class VIntUtils
5555
/// extra high bits set.</returns>
5656
public static bool TryReadVInt32(ReadOnlySpan<byte> source, out int value, out int count)
5757
{
58-
Debug.Assert(source.Length >= MaxVInt32Length);
58+
Debug.Assert(source.Length >= 1);
5959
byte b = source[0];
6060
if (b <= sbyte.MaxValue) // LUCENENET: Optimized equivalent of "if ((sbyte)b >= 0)"
6161
{
@@ -98,8 +98,8 @@ public static bool TryReadVInt32(ReadOnlySpan<byte> source, out int value, out i
9898

9999
/// <summary>
100100
/// Tries to read a 64-bit VInt from the given <paramref name="source"/>.
101-
/// <paramref name="source"/> must be at least <see cref="MaxVInt64Length"/> bytes
102-
/// in length to avoid possible out-of-range exceptions.
101+
/// <paramref name="source"/> must be at least 1 byte in length, and be well-formed if multibyte,
102+
/// to avoid possible out-of-range exceptions.
103103
/// </summary>
104104
/// <param name="source">The source bytes to read from.</param>
105105
/// <param name="value">The decoded value (undefined if the method returns <c>false</c>).</param>
@@ -109,7 +109,7 @@ public static bool TryReadVInt32(ReadOnlySpan<byte> source, out int value, out i
109109
/// the continuation bit set (which would indicate a negative value, disallowed).</returns>
110110
public static bool TryReadVInt64(ReadOnlySpan<byte> source, out long value, out int count)
111111
{
112-
Debug.Assert(source.Length >= MaxVInt64Length);
112+
Debug.Assert(source.Length >= 1);
113113
byte b = source[0];
114114
if (b <= sbyte.MaxValue)
115115
{

0 commit comments

Comments
 (0)