Skip to content
Merged
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 @@ -459,8 +459,7 @@ private static void ParseJson(
AppendNumberToken(
ref metaDb,
location,
tokenLength,
reader);
tokenLength);
break;

case JsonTokenType.True:
Expand Down Expand Up @@ -531,41 +530,17 @@ private static void AppendStringToken(
tokenType,
startLocation,
tokenLength,
hasComplexChildren: ContainsEscapeSequences(reader));
hasComplexChildren: reader.ValueIsEscaped);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void AppendNumberToken(
ref MetaDb metaDb,
int startLocation,
int tokenLength,
Utf8JsonReader reader)
int tokenLength)
=> metaDb.Append(
JsonTokenType.Number,
startLocation,
tokenLength,
hasComplexChildren: ContainsScientificNotation(reader.ValueSpan));

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static bool ContainsEscapeSequences(Utf8JsonReader reader)
{
if (reader.HasValueSequence)
{
foreach (var segment in reader.ValueSequence)
{
if (segment.Span.IndexOf(JsonConstants.BackSlash) >= 0)
{
return true;
}
}

return false;
}

return reader.ValueSpan.IndexOf(JsonConstants.BackSlash) is not -1;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static bool ContainsScientificNotation(ReadOnlySpan<byte> value)
=> value.IndexOfAny((byte)'e', (byte)'E') >= 0;
hasComplexChildren: false);
}
Loading