Use Ordinal comparisons

This commit is contained in:
Ottermandias 2022-06-20 18:26:40 +02:00
parent 47cfaf4da2
commit 6ebf550284
14 changed files with 19 additions and 20 deletions

View file

@ -72,9 +72,9 @@ public readonly struct FullPath : IComparable, IEquatable< FullPath >
=> obj switch
{
FullPath p => InternalName?.CompareTo( p.InternalName ) ?? -1,
FileInfo f => string.Compare( FullName, f.FullName, StringComparison.InvariantCultureIgnoreCase ),
FileInfo f => string.Compare( FullName, f.FullName, StringComparison.OrdinalIgnoreCase ),
Utf8String u => InternalName?.CompareTo( u ) ?? -1,
string s => string.Compare( FullName, s, StringComparison.InvariantCultureIgnoreCase ),
string s => string.Compare( FullName, s, StringComparison.OrdinalIgnoreCase ),
_ => -1,
};

View file

@ -38,14 +38,14 @@ public sealed unsafe partial class Utf8String : IDisposable
// Can throw ArgumentOutOfRange if length is higher than max length.
// The Crc32 will be computed.
public static Utf8String FromByteStringUnsafe( byte* path, int length, bool isNullTerminated, bool? isLower = null, bool? isAscii = false )
=> FromSpanUnsafe( new ReadOnlySpan< byte >( path, length ), isNullTerminated, isLower, isAscii );
=> new Utf8String().Setup( path, length, null, isNullTerminated, false, isLower, isAscii );
// Same as above, just with a span.
public static Utf8String FromSpanUnsafe( ReadOnlySpan< byte > path, bool isNullTerminated, bool? isLower = null, bool? isAscii = false )
{
fixed( byte* ptr = path )
{
return new Utf8String().Setup( ptr, path.Length, null, isNullTerminated, false, isLower, isAscii );
return FromByteStringUnsafe( ptr, path.Length, isNullTerminated, isLower, isAscii );
}
}

View file

@ -70,8 +70,8 @@ public readonly struct GamePath : IComparable
{
return rhs switch
{
string path => string.Compare( _path, path, StringComparison.InvariantCulture ),
GamePath path => string.Compare( _path, path._path, StringComparison.InvariantCulture ),
string path => string.Compare( _path, path, StringComparison.Ordinal ),
GamePath path => string.Compare( _path, path._path, StringComparison.Ordinal ),
_ => -1,
};
}