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

◆ CheckLiteralMultiSegment()

bool System.Text.Json.Utf8JsonReader.CheckLiteralMultiSegment ( ReadOnlySpan< byte > span,
ReadOnlySpan< byte > literal,
out int consumed )
inlineprivate

Definition at line 2353 of file Utf8JsonReader.cs.

2354 {
2355 Span<byte> destination = stackalloc byte[5];
2356 int num = 0;
2358 SequencePosition currentPosition = _currentPosition;
2359 if (span.Length >= literal.Length || IsLastSpan)
2360 {
2362 int num2 = Math.Min(span.Length, (int)_bytePositionInLine + 1);
2363 span.Slice(0, num2).CopyTo(destination);
2364 num += num2;
2365 }
2366 else if (!literal.StartsWith(span))
2367 {
2369 int num3 = Math.Min(span.Length, (int)_bytePositionInLine + 1);
2370 span.Slice(0, num3).CopyTo(destination);
2371 num += num3;
2372 }
2373 else
2374 {
2375 ReadOnlySpan<byte> readOnlySpan = literal.Slice(span.Length);
2376 SequencePosition currentPosition2 = _currentPosition;
2377 int consumed2 = _consumed;
2378 int num4 = literal.Length - readOnlySpan.Length;
2379 while (true)
2380 {
2383 if (!GetNextSpan())
2384 {
2386 consumed = 0;
2388 if (IsLastSpan)
2389 {
2390 break;
2391 }
2392 return false;
2393 }
2394 int num5 = Math.Min(span.Length, destination.Length - num);
2395 span.Slice(0, num5).CopyTo(destination.Slice(num));
2396 num += num5;
2397 span = _buffer;
2398 if (span.StartsWith(readOnlySpan))
2399 {
2400 HasValueSequence = true;
2401 SequencePosition start = new SequencePosition(currentPosition2.GetObject(), currentPosition2.GetInteger() + consumed2);
2402 SequencePosition end = new SequencePosition(_currentPosition.GetObject(), _currentPosition.GetInteger() + readOnlySpan.Length);
2404 consumed = readOnlySpan.Length;
2405 return true;
2406 }
2407 if (!readOnlySpan.StartsWith(span))
2408 {
2410 num5 = Math.Min(span.Length, (int)_bytePositionInLine + 1);
2411 span.Slice(0, num5).CopyTo(destination.Slice(num));
2412 num += num5;
2413 break;
2414 }
2415 readOnlySpan = readOnlySpan.Slice(span.Length);
2416 num4 = span.Length;
2417 }
2418 }
2420 consumed = 0;
2422 throw GetInvalidLiteralMultiSegment(destination.Slice(0, num).ToArray());
2423 }
ReadOnlySequence< T > Slice(long start, long length)
JsonException GetInvalidLiteralMultiSegment(ReadOnlySpan< byte > span)
readonly ReadOnlySequence< byte > _sequence
int FindMismatch(ReadOnlySpan< byte > span, ReadOnlySpan< byte > literal)
ReadOnlySequence< byte > ValueSequence

References System.Text.Json.Utf8JsonReader._buffer, System.Text.Json.Utf8JsonReader._bytePositionInLine, System.Text.Json.Utf8JsonReader._consumed, System.Text.Json.Utf8JsonReader._currentPosition, System.Text.Json.Utf8JsonReader._sequence, System.Text.Json.Utf8JsonReader._totalConsumed, System.destination, System.Text.Json.Dictionary, System.Text.Json.Utf8JsonReader.FindMismatch(), System.SequencePosition.GetInteger(), System.Text.Json.Utf8JsonReader.GetInvalidLiteralMultiSegment(), System.Text.Json.Utf8JsonReader.GetNextSpan(), System.SequencePosition.GetObject(), System.Text.Json.Utf8JsonReader.HasValueSequence, System.Text.Json.Utf8JsonReader.IsLastSpan, System.Math.Min(), System.ReadOnlySpan< T >.Slice(), System.Buffers.ReadOnlySequence< T >.Slice(), System.start, and System.Text.Json.Utf8JsonReader.ValueSequence.

Referenced by System.Text.Json.Utf8JsonReader.ConsumeLiteralMultiSegment().