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
|
|
@ -387,7 +387,7 @@ namespace Server
|
|||
var sectionStart = 0;
|
||||
var hasCompressor = false;
|
||||
|
||||
var num = BinaryPrimitives.ReadUInt16BigEndian(ip.SliceToLength(2));
|
||||
var num = BinaryPrimitives.ReadUInt16BigEndian(ip[..2]);
|
||||
|
||||
for (int i = 0; i < end; i++)
|
||||
{
|
||||
|
|
@ -473,10 +473,10 @@ namespace Server
|
|||
// IPv4 matching at the end
|
||||
if (section == 6 && num == 0xFFFF)
|
||||
{
|
||||
var ipv4 = val.Slice(i + 1);
|
||||
var ipv4 = val[(i + 1)..];
|
||||
if (ipv4.Contains('.'))
|
||||
{
|
||||
return IPv4Match(ipv4, ip.Slice(ip.Length - 4), out valid);
|
||||
return IPv4Match(ipv4, ip[^4..], out valid);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -504,7 +504,7 @@ namespace Server
|
|||
|
||||
if (i + 1 < end)
|
||||
{
|
||||
var remainingColons = val.Slice(i + 1).Count(':');
|
||||
var remainingColons = val[(i + 1)..].Count(':');
|
||||
// double colon must be at least 2 sections
|
||||
// we need at least 1 section remaining out of 8
|
||||
// This means 8 - 2 would be 6 sections (5 colons)
|
||||
|
|
@ -972,7 +972,7 @@ namespace Server
|
|||
#pragma warning disable CA1806 // Do not ignore method results
|
||||
if (value.StartsWithOrdinal("0x"))
|
||||
{
|
||||
int.TryParse(value.Slice(2), NumberStyles.HexNumber, null, out i);
|
||||
int.TryParse(value[2..], NumberStyles.HexNumber, null, out i);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -990,7 +990,7 @@ namespace Server
|
|||
#pragma warning disable CA1806 // Do not ignore method results
|
||||
if (value.InsensitiveStartsWith("0x"))
|
||||
{
|
||||
uint.TryParse(value.Slice(2), NumberStyles.HexNumber, null, out i);
|
||||
uint.TryParse(value[2..], NumberStyles.HexNumber, null, out i);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1003,12 +1003,12 @@ namespace Server
|
|||
|
||||
public static bool ToInt32(ReadOnlySpan<char> value, out int i) =>
|
||||
value.InsensitiveStartsWith("0x")
|
||||
? int.TryParse(value.Slice(2), NumberStyles.HexNumber, null, out i)
|
||||
? int.TryParse(value[2..], NumberStyles.HexNumber, null, out i)
|
||||
: int.TryParse(value, out i);
|
||||
|
||||
public static bool ToUInt32(ReadOnlySpan<char> value, out uint i) =>
|
||||
value.InsensitiveStartsWith("0x")
|
||||
? uint.TryParse(value.Slice(2), NumberStyles.HexNumber, null, out i)
|
||||
? uint.TryParse(value[2..], NumberStyles.HexNumber, null, out i)
|
||||
: uint.TryParse(value, out i);
|
||||
|
||||
public static int GetXMLInt32(string intString, int defaultValue)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue