Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ TryGetNamedPropertyValue() [3/3]

bool System.Text.Json.JsonDocument.TryGetNamedPropertyValue ( int startIndex,
int endIndex,
ReadOnlySpan< byte > propertyName,
out JsonElement value )
inlineprivate

Definition at line 1634 of file JsonDocument.cs.

1635 {
1636 ReadOnlySpan<byte> span = _utf8Json.Span;
1637 Span<byte> span2 = stackalloc byte[256];
1638 int num;
1639 for (num = endIndex - 12; num > startIndex; num -= 12)
1640 {
1641 DbRow dbRow = _parsedData.Get(num);
1642 num = ((!dbRow.IsSimpleValue) ? (num - 12 * (dbRow.NumberOfRows + 1)) : (num - 12));
1643 dbRow = _parsedData.Get(num);
1644 ReadOnlySpan<byte> span3 = span.Slice(dbRow.Location, dbRow.SizeOrLength);
1645 if (dbRow.HasComplexChildren)
1646 {
1647 if (span3.Length > propertyName.Length)
1648 {
1649 int num2 = span3.IndexOf<byte>(92);
1650 if (propertyName.Length > num2 && span3.Slice(0, num2).SequenceEqual(propertyName.Slice(0, num2)))
1651 {
1652 int num3 = span3.Length - num2;
1653 int written = 0;
1654 byte[] array = null;
1655 try
1656 {
1657 Span<byte> destination = ((num3 <= span2.Length) ? span2 : ((Span<byte>)(array = ArrayPool<byte>.Shared.Rent(num3))));
1658 JsonReaderHelper.Unescape(span3.Slice(num2), destination, 0, out written);
1659 if (destination.Slice(0, written).SequenceEqual(propertyName.Slice(num2)))
1660 {
1661 value = new JsonElement(this, num + 12);
1662 return true;
1663 }
1664 }
1665 finally
1666 {
1667 if (array != null)
1668 {
1669 array.AsSpan(0, written).Clear();
1671 }
1672 }
1673 }
1674 }
1675 }
1676 else if (span3.SequenceEqual(propertyName))
1677 {
1678 value = new JsonElement(this, num + 12);
1679 return true;
1680 }
1681 }
1682 value = default(JsonElement);
1683 return false;
1684 }
static ArrayPool< T > Shared
Definition ArrayPool.cs:7
ReadOnlyMemory< byte > _utf8Json
unsafe ReadOnlySpan< T > Span

References System.Text.Json.JsonDocument._parsedData, System.Text.Json.JsonDocument._utf8Json, System.array, System.destination, System.Text.Json.Dictionary, System.endIndex, System.Text.Json.JsonDocument.MetadataDb.Get(), System.Buffers.ArrayPool< T >.Rent(), System.Buffers.ArrayPool< T >.Shared, System.ReadOnlySpan< T >.Slice(), System.ReadOnlyMemory< T >.Span, System.startIndex, System.Text.Json.JsonReaderHelper.Unescape(), and System.value.