Skip to content

Commit 1bb3bca

Browse files
Use new MemoryExtensions.Count and Json.WriteRawValue methods (#46332)
1 parent 4f6a03e commit 1bb3bca

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/Identity/Extensions.Stores/src/UserStoreBase.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,9 @@ public virtual async Task<int> CountCodesAsync(TUser user, CancellationToken can
920920
var mergedCodes = await GetTokenAsync(user, InternalLoginProvider, RecoveryCodeTokenName, cancellationToken).ConfigureAwait(false) ?? "";
921921
if (mergedCodes.Length > 0)
922922
{
923+
#if NET8_0_OR_GREATER
924+
return mergedCodes.AsSpan().Count(';') + 1;
925+
#else
923926
// non-allocating version of mergedCodes.Split(';').Length
924927
var count = 1;
925928
var index = 0;
@@ -934,6 +937,7 @@ public virtual async Task<int> CountCodesAsync(TUser user, CancellationToken can
934937
index = semiColonIndex + 1;
935938
}
936939
return count;
940+
#endif
937941
}
938942
return 0;
939943
}

src/SignalR/common/Protocols.Json/src/Protocol/JsonHubProtocol.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -588,15 +588,7 @@ private void WriteCompletionMessage(CompletionMessage message, Utf8JsonWriter wr
588588
{
589589
if (message.Result is RawResult result)
590590
{
591-
if (result.RawSerializedData.IsSingleSegment)
592-
{
593-
writer.WriteRawValue(result.RawSerializedData.First.Span, skipInputValidation: true);
594-
}
595-
else
596-
{
597-
// https://github.com/dotnet/runtime/issues/68223
598-
writer.WriteRawValue(result.RawSerializedData.ToArray(), skipInputValidation: true);
599-
}
591+
writer.WriteRawValue(result.RawSerializedData, skipInputValidation: true);
600592
}
601593
else
602594
{

0 commit comments

Comments
 (0)