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
|
|
@ -89,7 +89,7 @@ namespace Server
|
|||
|
||||
int index = buffer.IndexOfTerminator(sizeT);
|
||||
|
||||
var span = buffer.SliceToLength(index < 0 ? size : index);
|
||||
var span = buffer[..(index < 0 ? size : index)];
|
||||
_position += isFixedLength || index < 0 ? size : index + sizeT;
|
||||
return TextEncoding.GetString(span, encoding, safeString);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ namespace Server
|
|||
Span<byte> stack = stackalloc byte[16];
|
||||
value.TryWriteBytes(stack, out var bytesWritten);
|
||||
Write((byte)bytesWritten);
|
||||
Write(stack.SliceToLength(bytesWritten));
|
||||
Write(stack[..bytesWritten]);
|
||||
}
|
||||
|
||||
public void Write(TimeSpan value)
|
||||
|
|
@ -441,7 +441,7 @@ namespace Server
|
|||
charsLeft -= charCount;
|
||||
current += charCount;
|
||||
|
||||
Write(span.SliceToLength(bytesWritten));
|
||||
Write(span[..bytesWritten]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue