fix: Cleans up string substring (#1018)

This commit is contained in:
Kamron Batman 2022-05-14 16:56:03 -07:00 • committed by GitHub
parent 87b63b38a5
commit 6ec84b3c01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 40 additions and 40 deletions

View file

@ -484,9 +484,14 @@ public sealed class Map : IComparable<Map>
return mapValues;
}
public static Map Parse(string value)
// Handles null checks
public static Map Parse(string value) => Parse(value ?? ReadOnlySpan<char>.Empty);
public static Map Parse(ReadOnlySpan<char> value)
{
if (string.IsNullOrWhiteSpace(value))
value = value.Trim();
if (value.Length == 0)
{
return null;
}
@ -513,7 +518,7 @@ public sealed class Map : IComparable<Map>
continue;
}
if (index >= 0 && map.MapIndex == index || map.Name.InsensitiveEquals(value))
if (index >= 0 && map.MapIndex == index || value.InsensitiveEquals(map.Name))
{
return map;
}