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
|
|
@ -50,11 +50,11 @@ namespace Server.Network
|
|||
{
|
||||
if (!_finished)
|
||||
{
|
||||
BinaryPrimitives.WriteUInt16BigEndian(_bytes.Slice(1, 2), (ushort)Length);
|
||||
BinaryPrimitives.WriteUInt16BigEndian(_bytes.Slice(3, 2), (ushort)_count);
|
||||
BinaryPrimitives.WriteUInt16BigEndian(_bytes[1..3], (ushort)Length);
|
||||
BinaryPrimitives.WriteUInt16BigEndian(_bytes[3..5], (ushort)_count);
|
||||
}
|
||||
|
||||
return _bytes.SliceToLength(Length);
|
||||
return _bytes[..Length];
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
|
|
@ -70,7 +70,7 @@ namespace Server.Network
|
|||
Grow(bytesNeeded);
|
||||
}
|
||||
|
||||
return _bytes.Slice(Length);
|
||||
return _bytes[Length..];
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
|
|
@ -91,7 +91,7 @@ namespace Server.Network
|
|||
var newLength = Math.Max(Length + additionalCapacityBeyondPos, _bytes.Length * 2);
|
||||
byte[] poolArray = ArrayPool<byte>.Shared.Rent(newLength);
|
||||
|
||||
_bytes.SliceToLength(Length).CopyTo(poolArray);
|
||||
_bytes[..Length].CopyTo(poolArray);
|
||||
|
||||
byte[] toReturn = _arrayToReturnToPool;
|
||||
_bytes = _arrayToReturnToPool = poolArray;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue