Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Commit 0ee4a86

Browse files
ahsonkhandavidfowl
authored andcommitted
Collapse AsSpan().Slice(..) into AsSpan(..) (#1991)
1 parent 16c6a65 commit 0ee4a86

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Common/MemoryBufferWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ public override void Write(byte[] buffer, int offset, int count)
288288
#if NETCOREAPP2_1
289289
public override void Write(ReadOnlySpan<byte> span)
290290
{
291-
if (_currentSegment != null && span.TryCopyTo(_currentSegment.AsSpan().Slice(_position)))
291+
if (_currentSegment != null && span.TryCopyTo(_currentSegment.AsSpan(_position)))
292292
{
293293
_position += span.Length;
294294
_bytesWritten += span.Length;

test/Microsoft.AspNetCore.SignalR.Tests/EndToEndTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public async Task WebSocketsTest()
107107
var result = await ws.ReceiveAsync(buffer, CancellationToken.None).OrTimeout();
108108
logger.LogInformation("Received {length} byte frame", result.Count);
109109

110-
Assert.Equal(bytes, buffer.Array.AsSpan().Slice(0, result.Count).ToArray());
110+
Assert.Equal(bytes, buffer.Array.AsSpan(0, result.Count).ToArray());
111111

112112
logger.LogInformation("Closing socket");
113113
await ws.CloseOutputAsync(WebSocketCloseStatus.Empty, "", CancellationToken.None).OrTimeout();
@@ -145,7 +145,7 @@ public async Task WebSocketsReceivesAndSendsPartialFramesTest()
145145
var result = await ws.ReceiveAsync(buffer, CancellationToken.None).OrTimeout();
146146
logger.LogInformation("Received {length} byte frame", result.Count);
147147

148-
Assert.Equal(bytes, buffer.Array.AsSpan().Slice(0, result.Count).ToArray());
148+
Assert.Equal(bytes, buffer.Array.AsSpan(0, result.Count).ToArray());
149149

150150
logger.LogInformation("Closing socket");
151151
await ws.CloseOutputAsync(WebSocketCloseStatus.Empty, "", CancellationToken.None).OrTimeout();

0 commit comments

Comments
 (0)