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
|
|
@ -64,14 +64,14 @@ namespace Server.Tests.Network
|
|||
var strLength = fixedLength > -1 ? Math.Min(value.Length, fixedLength) : value.Length;
|
||||
var chars = value.AsSpan(0, strLength);
|
||||
|
||||
encoding.GetBytes(chars, buffer.Slice(offset));
|
||||
encoding.GetBytes(chars, buffer[offset..]);
|
||||
|
||||
var reader = new CircularBufferReader(buffer.SliceToLength(firstSize), buffer.Slice(firstSize));
|
||||
var reader = new CircularBufferReader(buffer[..firstSize], buffer[firstSize..]);
|
||||
reader.Seek(offset, SeekOrigin.Begin);
|
||||
|
||||
var actual = reader.ReadString(encoding, isSafe, fixedLength);
|
||||
|
||||
Assert.Equal(value.Substring(0, strLength), actual);
|
||||
Assert.Equal(value[..strLength], actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -82,7 +82,7 @@ namespace Server.Tests.Network
|
|||
expected[1] = 0x1;
|
||||
expected[2] = 0x1;
|
||||
expected[3] = 0x1;
|
||||
Encoding.ASCII.GetBytes("TestString", expected.Slice(4, 10));
|
||||
Encoding.ASCII.GetBytes("TestString", expected[4..14]);
|
||||
expected[14] = 0x0; // Null
|
||||
expected[15] = 0x2;
|
||||
expected[16] = 0x2;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue