Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reuse local variable
  • Loading branch information
etemi committed Aug 16, 2024
commit ea276ea6ba43a52c8380bf8d6c074d815a12d289
Original file line number Diff line number Diff line change
Expand Up @@ -950,8 +950,7 @@ private static void Parse(
ref StackRowStack stack)
{
bool inArray = false;
int numberOfProperties = 0;
int arrayItemsCount = 0;
int arrayItemsOrPropertyCount = 0;
int numberOfRowsForMembers = 0;
int numberOfRowsForValues = 0;

Expand All @@ -973,14 +972,14 @@ private static void Parse(
{
if (inArray)
{
arrayItemsCount++;
arrayItemsOrPropertyCount++;
}

numberOfRowsForValues++;
database.Append(tokenType, tokenStart, DbRow.UnknownSize);
var row = new StackRow(numberOfProperties, numberOfRowsForMembers + 1);
var row = new StackRow(arrayItemsOrPropertyCount, numberOfRowsForMembers + 1);
stack.Push(row);
numberOfProperties = 0;
arrayItemsOrPropertyCount = 0;
numberOfRowsForMembers = 0;
}
else if (tokenType == JsonTokenType.EndObject)
Expand All @@ -989,29 +988,29 @@ private static void Parse(

numberOfRowsForValues++;
numberOfRowsForMembers++;
database.SetLength(rowIndex, numberOfProperties);
database.SetLength(rowIndex, arrayItemsOrPropertyCount);

int newRowIndex = database.Length;
database.Append(tokenType, tokenStart, reader.ValueSpan.Length);
database.SetNumberOfRows(rowIndex, numberOfRowsForMembers);
database.SetNumberOfRows(newRowIndex, numberOfRowsForMembers);

StackRow row = stack.Pop();
numberOfProperties = row.SizeOrLength;
arrayItemsOrPropertyCount = row.SizeOrLength;
numberOfRowsForMembers += row.NumberOfRows;
}
else if (tokenType == JsonTokenType.StartArray)
{
if (inArray)
{
arrayItemsCount++;
arrayItemsOrPropertyCount++;
}

numberOfRowsForMembers++;
database.Append(tokenType, tokenStart, DbRow.UnknownSize);
var row = new StackRow(arrayItemsCount, numberOfRowsForValues + 1);
var row = new StackRow(arrayItemsOrPropertyCount, numberOfRowsForValues + 1);
stack.Push(row);
arrayItemsCount = 0;
arrayItemsOrPropertyCount = 0;
numberOfRowsForValues = 0;
}
else if (tokenType == JsonTokenType.EndArray)
Expand All @@ -1020,7 +1019,7 @@ private static void Parse(

numberOfRowsForValues++;
numberOfRowsForMembers++;
database.SetLength(rowIndex, arrayItemsCount);
database.SetLength(rowIndex, arrayItemsOrPropertyCount);
database.SetNumberOfRows(rowIndex, numberOfRowsForValues);

// If the array item count is (e.g.) 12 and the number of rows is (e.g.) 13
Expand All @@ -1033,7 +1032,7 @@ private static void Parse(
// This check is similar to tracking the start array and painting it when
// StartObject or StartArray is encountered, but avoids the mixed state
// where "UnknownSize" implies "has complex children".
if (arrayItemsCount + 1 != numberOfRowsForValues)
if (arrayItemsOrPropertyCount + 1 != numberOfRowsForValues)
{
database.SetHasComplexChildren(rowIndex);
}
Expand All @@ -1043,14 +1042,14 @@ private static void Parse(
database.SetNumberOfRows(newRowIndex, numberOfRowsForValues);

StackRow row = stack.Pop();
arrayItemsCount = row.SizeOrLength;
arrayItemsOrPropertyCount = row.SizeOrLength;
numberOfRowsForValues += row.NumberOfRows;
}
else if (tokenType == JsonTokenType.PropertyName)
{
numberOfRowsForValues++;
numberOfRowsForMembers++;
numberOfProperties++;
arrayItemsOrPropertyCount++;

// Adding 1 to skip the start quote will never overflow
Debug.Assert(tokenStart < int.MaxValue);
Expand All @@ -1072,7 +1071,7 @@ private static void Parse(

if (inArray)
{
arrayItemsCount++;
arrayItemsOrPropertyCount++;
}

if (tokenType == JsonTokenType.String)
Expand Down