Skip to content

Commit

Permalink
Better variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
YohDeadfall committed Oct 19, 2022
1 parent c11d048 commit f9d3bed
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/libraries/System.Text.Json/Common/JsonSeparatorNamingPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public sealed override string ConvertName(string name)
? ArrayPool<char>.Shared.Rent(rentedBufferLength)
: null;

int resultLength = 0;
int resultUsedLength = 0;
Span<char> result = rentedBuffer is null
? stackalloc char[JsonConstants.StackallocCharThreshold]
: rentedBuffer;
Expand All @@ -35,7 +35,7 @@ void ExpandBuffer(ref Span<char> result)

if (rentedBuffer is not null)
{
result.Slice(0, resultLength).Clear();
result.Slice(0, resultUsedLength).Clear();
ArrayPool<char>.Shared.Return(rentedBuffer);
}

Expand All @@ -53,9 +53,9 @@ void WriteWord(ReadOnlySpan<char> word, ref Span<char> result)
int written;
while (true)
{
var destinationOffset = resultLength != 0
? resultLength + 1
: resultLength;
var destinationOffset = resultUsedLength != 0
? resultUsedLength + 1
: resultUsedLength;

if (destinationOffset < result.Length)
{
Expand All @@ -74,13 +74,13 @@ void WriteWord(ReadOnlySpan<char> word, ref Span<char> result)
ExpandBuffer(ref result);
}

if (resultLength != 0)
if (resultUsedLength != 0)
{
result[resultLength] = _separator;
resultLength += 1;
result[resultUsedLength] = _separator;
resultUsedLength += 1;
}

resultLength += written;
resultUsedLength += written;
}

int first = 0;
Expand Down Expand Up @@ -143,11 +143,11 @@ void WriteWord(ReadOnlySpan<char> word, ref Span<char> result)

WriteWord(chars.Slice(first), ref result);

name = result.Slice(0, resultLength).ToString();
name = result.Slice(0, resultUsedLength).ToString();

if (rentedBuffer is not null)
{
result.Slice(0, resultLength).Clear();
result.Slice(0, resultUsedLength).Clear();
ArrayPool<char>.Shared.Return(rentedBuffer);
}

Expand Down

0 comments on commit f9d3bed

Please sign in to comment.