fix(core): Updates slice with range selectors (#583)
- [X] Replaces Span slicing with range selection - [X] Replaces string slicing with range selection
This commit is contained in:
parent
9f9d990f85
commit
a0893b68c0
62 changed files with 363 additions and 382 deletions
|
|
@ -55,7 +55,7 @@ namespace Server.Tests.Buffers
|
|||
var strLength = fixedLength > -1 ? Math.Min(value.Length, fixedLength) : value.Length;
|
||||
var chars = value.AsSpan(0, strLength);
|
||||
|
||||
var writer = new CircularBufferWriter(buffer.SliceToLength(firstSize), buffer.Slice(firstSize));
|
||||
var writer = new CircularBufferWriter(buffer[..firstSize], buffer[firstSize..]);
|
||||
writer.Seek(offset, SeekOrigin.Begin);
|
||||
writer.WriteString(chars, encoding);
|
||||
|
||||
|
|
@ -63,11 +63,11 @@ namespace Server.Tests.Buffers
|
|||
{
|
||||
Span<byte> testEmpty = stackalloc byte[offset];
|
||||
testEmpty.Clear();
|
||||
AssertThat.Equal(buffer.SliceToLength(offset), testEmpty);
|
||||
AssertThat.Equal(buffer[..offset], testEmpty);
|
||||
}
|
||||
|
||||
Span<byte> expectedStr = stackalloc byte[encoding.GetByteCount(chars)];
|
||||
encoding.GetBytes(chars, expectedStr.Slice(0));
|
||||
encoding.GetBytes(chars, expectedStr[..]);
|
||||
|
||||
AssertThat.Equal(buffer.Slice(offset, expectedStr.Length), expectedStr);
|
||||
offset += expectedStr.Length;
|
||||
|
|
@ -76,7 +76,7 @@ namespace Server.Tests.Buffers
|
|||
{
|
||||
Span<byte> testEmpty = stackalloc byte[buffer.Length - offset];
|
||||
testEmpty.Clear();
|
||||
AssertThat.Equal(buffer.Slice(offset), testEmpty);
|
||||
AssertThat.Equal(buffer[offset..], testEmpty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue