From 09a5177a254f1e50684a18d81ff7fb307ef08e0e Mon Sep 17 00:00:00 2001 From: Ahson Khan Date: Thu, 12 Apr 2018 23:02:29 -0700 Subject: [PATCH] Collapse AsSpan().Slice(..) into AsSpan(..) --- src/Common/MemoryBufferWriter.cs | 2 +- test/Microsoft.AspNetCore.SignalR.Tests/EndToEndTests.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Common/MemoryBufferWriter.cs b/src/Common/MemoryBufferWriter.cs index adf5820429..2b0fa29d62 100644 --- a/src/Common/MemoryBufferWriter.cs +++ b/src/Common/MemoryBufferWriter.cs @@ -288,7 +288,7 @@ public override void Write(byte[] buffer, int offset, int count) #if NETCOREAPP2_1 public override void Write(ReadOnlySpan span) { - if (_currentSegment != null && span.TryCopyTo(_currentSegment.AsSpan().Slice(_position))) + if (_currentSegment != null && span.TryCopyTo(_currentSegment.AsSpan(_position))) { _position += span.Length; _bytesWritten += span.Length; diff --git a/test/Microsoft.AspNetCore.SignalR.Tests/EndToEndTests.cs b/test/Microsoft.AspNetCore.SignalR.Tests/EndToEndTests.cs index 0bebfc3ebc..58cba9e36a 100644 --- a/test/Microsoft.AspNetCore.SignalR.Tests/EndToEndTests.cs +++ b/test/Microsoft.AspNetCore.SignalR.Tests/EndToEndTests.cs @@ -107,7 +107,7 @@ public async Task WebSocketsTest() var result = await ws.ReceiveAsync(buffer, CancellationToken.None).OrTimeout(); logger.LogInformation("Received {length} byte frame", result.Count); - Assert.Equal(bytes, buffer.Array.AsSpan().Slice(0, result.Count).ToArray()); + Assert.Equal(bytes, buffer.Array.AsSpan(0, result.Count).ToArray()); logger.LogInformation("Closing socket"); await ws.CloseOutputAsync(WebSocketCloseStatus.Empty, "", CancellationToken.None).OrTimeout(); @@ -145,7 +145,7 @@ public async Task WebSocketsReceivesAndSendsPartialFramesTest() var result = await ws.ReceiveAsync(buffer, CancellationToken.None).OrTimeout(); logger.LogInformation("Received {length} byte frame", result.Count); - Assert.Equal(bytes, buffer.Array.AsSpan().Slice(0, result.Count).ToArray()); + Assert.Equal(bytes, buffer.Array.AsSpan(0, result.Count).ToArray()); logger.LogInformation("Closing socket"); await ws.CloseOutputAsync(WebSocketCloseStatus.Empty, "", CancellationToken.None).OrTimeout();