Skip to content

Commit d333c52

Browse files
authored
[Fusion] Eliminate redundant parse-flag rescans in SourceResultDocument (#10082)
1 parent ead15e2 commit d333c52

1 file changed

Lines changed: 4 additions & 29 deletions

File tree

src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/SourceResultDocument.Parse.cs

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,7 @@ private static void ParseJson(
459459
AppendNumberToken(
460460
ref metaDb,
461461
location,
462-
tokenLength,
463-
reader);
462+
tokenLength);
464463
break;
465464

466465
case JsonTokenType.True:
@@ -531,41 +530,17 @@ private static void AppendStringToken(
531530
tokenType,
532531
startLocation,
533532
tokenLength,
534-
hasComplexChildren: ContainsEscapeSequences(reader));
533+
hasComplexChildren: reader.ValueIsEscaped);
535534
}
536535

537536
[MethodImpl(MethodImplOptions.AggressiveInlining)]
538537
private static void AppendNumberToken(
539538
ref MetaDb metaDb,
540539
int startLocation,
541-
int tokenLength,
542-
Utf8JsonReader reader)
540+
int tokenLength)
543541
=> metaDb.Append(
544542
JsonTokenType.Number,
545543
startLocation,
546544
tokenLength,
547-
hasComplexChildren: ContainsScientificNotation(reader.ValueSpan));
548-
549-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
550-
private static bool ContainsEscapeSequences(Utf8JsonReader reader)
551-
{
552-
if (reader.HasValueSequence)
553-
{
554-
foreach (var segment in reader.ValueSequence)
555-
{
556-
if (segment.Span.IndexOf(JsonConstants.BackSlash) >= 0)
557-
{
558-
return true;
559-
}
560-
}
561-
562-
return false;
563-
}
564-
565-
return reader.ValueSpan.IndexOf(JsonConstants.BackSlash) is not -1;
566-
}
567-
568-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
569-
private static bool ContainsScientificNotation(ReadOnlySpan<byte> value)
570-
=> value.IndexOfAny((byte)'e', (byte)'E') >= 0;
545+
hasComplexChildren: false);
571546
}

0 commit comments

Comments
 (0)