Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ internal Cursor GetEndIndex(Cursor cursor, bool includeEndElement)
return endId;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal DbRow GetDbRow(Cursor cursor) => _parsedData.Get(cursor);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static int GetEndRowLength(DbRow endRow)
=> endRow.TokenType is JsonTokenType.EndObject or JsonTokenType.EndArray
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ public bool MoveNext()

// Already on an element: jump to just after this element (exclusive),
// which is the start of the next element if one exists.
var next = _target._parent.GetEndIndex(_current, includeEndElement: true);
// Inlined from GetEndIndex(_current, includeEndElement: true).
var row = _target._parent.GetDbRow(_current);
var next = row.IsSimpleValue ? _current + 1 : _current + row.NumberOfRows;

if (next < _endCursor)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,13 @@ public bool MoveNext()
}
}

// Advance past the current VALUE to the start of the next element.
// GetEndIndex(current, includeEndElement: true) yields the row after the current value.
var afterCurrent = _target._parent.GetEndIndex(_current, includeEndElement: true);
// Advance past the current VALUE to the row after it.
// Inlined from GetEndIndex(_current, includeEndElement: true) to avoid
// the method call overhead, disposed check, and branch on every iteration.
var row = _target._parent.GetDbRow(_current);
var afterCurrent = row.IsSimpleValue ? _current + 1 : _current + row.NumberOfRows;

// After a value, the next row (if any) is the next PropertyName; we need the VALUE,
// so we skip one more row.
// After the value comes the next PropertyName; skip it to reach the VALUE.
var nextValue = afterCurrent + 1;

if (nextValue < _endCursor)
Expand Down
Loading