mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Use Ordinal comparisons
This commit is contained in:
parent
47cfaf4da2
commit
6ebf550284
14 changed files with 19 additions and 20 deletions
2
OtterGui
2
OtterGui
|
|
@ -1 +1 @@
|
||||||
Subproject commit 6ce8ca816678e7a363f9f4a6f43f009f8d79c070
|
Subproject commit fa83386909ad0034f5ed7ea90d8bcedf6e8ba748
|
||||||
|
|
@ -72,9 +72,9 @@ public readonly struct FullPath : IComparable, IEquatable< FullPath >
|
||||||
=> obj switch
|
=> obj switch
|
||||||
{
|
{
|
||||||
FullPath p => InternalName?.CompareTo( p.InternalName ) ?? -1,
|
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,
|
Utf8String u => InternalName?.CompareTo( u ) ?? -1,
|
||||||
string s => string.Compare( FullName, s, StringComparison.InvariantCultureIgnoreCase ),
|
string s => string.Compare( FullName, s, StringComparison.OrdinalIgnoreCase ),
|
||||||
_ => -1,
|
_ => -1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,14 +38,14 @@ public sealed unsafe partial class Utf8String : IDisposable
|
||||||
// Can throw ArgumentOutOfRange if length is higher than max length.
|
// Can throw ArgumentOutOfRange if length is higher than max length.
|
||||||
// The Crc32 will be computed.
|
// The Crc32 will be computed.
|
||||||
public static Utf8String FromByteStringUnsafe( byte* path, int length, bool isNullTerminated, bool? isLower = null, bool? isAscii = false )
|
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.
|
// Same as above, just with a span.
|
||||||
public static Utf8String FromSpanUnsafe( ReadOnlySpan< byte > path, bool isNullTerminated, bool? isLower = null, bool? isAscii = false )
|
public static Utf8String FromSpanUnsafe( ReadOnlySpan< byte > path, bool isNullTerminated, bool? isLower = null, bool? isAscii = false )
|
||||||
{
|
{
|
||||||
fixed( byte* ptr = path )
|
fixed( byte* ptr = path )
|
||||||
{
|
{
|
||||||
return new Utf8String().Setup( ptr, path.Length, null, isNullTerminated, false, isLower, isAscii );
|
return FromByteStringUnsafe( ptr, path.Length, isNullTerminated, isLower, isAscii );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,8 +70,8 @@ public readonly struct GamePath : IComparable
|
||||||
{
|
{
|
||||||
return rhs switch
|
return rhs switch
|
||||||
{
|
{
|
||||||
string path => string.Compare( _path, path, StringComparison.InvariantCulture ),
|
string path => string.Compare( _path, path, StringComparison.Ordinal ),
|
||||||
GamePath path => string.Compare( _path, path._path, StringComparison.InvariantCulture ),
|
GamePath path => string.Compare( _path, path._path, StringComparison.Ordinal ),
|
||||||
_ => -1,
|
_ => -1,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ public partial class ModCollection
|
||||||
|
|
||||||
// Obtain a collection case-independently by name.
|
// Obtain a collection case-independently by name.
|
||||||
public bool ByName( string name, [NotNullWhen( true )] out ModCollection? collection )
|
public bool ByName( string name, [NotNullWhen( true )] out ModCollection? collection )
|
||||||
=> _collections.FindFirst( c => string.Equals( c.Name, name, StringComparison.InvariantCultureIgnoreCase ), out collection );
|
=> _collections.FindFirst( c => string.Equals( c.Name, name, StringComparison.OrdinalIgnoreCase ), out collection );
|
||||||
|
|
||||||
// Default enumeration skips the empty collection.
|
// Default enumeration skips the empty collection.
|
||||||
public IEnumerator< ModCollection > GetEnumerator()
|
public IEnumerator< ModCollection > GetEnumerator()
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ public partial class ModCollection
|
||||||
}
|
}
|
||||||
|
|
||||||
var iterator = ResolvedFiles
|
var iterator = ResolvedFiles
|
||||||
.Where( f => string.Equals( f.Value.Path.FullName, needle, StringComparison.InvariantCultureIgnoreCase ) )
|
.Where( f => string.Equals( f.Value.Path.FullName, needle, StringComparison.OrdinalIgnoreCase ) )
|
||||||
.Select( kvp => kvp.Key );
|
.Select( kvp => kvp.Key );
|
||||||
|
|
||||||
// For files that are not rooted, try to add themselves.
|
// For files that are not rooted, try to add themselves.
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ public class ResourceLogger : IDisposable
|
||||||
private string? Match( Utf8String data )
|
private string? Match( Utf8String data )
|
||||||
{
|
{
|
||||||
var s = data.ToString();
|
var s = data.ToString();
|
||||||
return Filter.Length == 0 || ( _filterRegex?.IsMatch( s ) ?? s.Contains( Filter, StringComparison.InvariantCultureIgnoreCase ) )
|
return Filter.Length == 0 || ( _filterRegex?.IsMatch( s ) ?? s.Contains( Filter, StringComparison.OrdinalIgnoreCase ) )
|
||||||
? s
|
? s
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -284,7 +284,7 @@ public sealed partial class Mod
|
||||||
var path = newName.RemoveInvalidPathSymbols();
|
var path = newName.RemoveInvalidPathSymbols();
|
||||||
if( path.Length == 0
|
if( path.Length == 0
|
||||||
|| mod.Groups.Any( o => !ReferenceEquals( o, group )
|
|| mod.Groups.Any( o => !ReferenceEquals( o, group )
|
||||||
&& string.Equals( o.Name.RemoveInvalidPathSymbols(), path, StringComparison.InvariantCultureIgnoreCase ) ) )
|
&& string.Equals( o.Name.RemoveInvalidPathSymbols(), path, StringComparison.OrdinalIgnoreCase ) ) )
|
||||||
{
|
{
|
||||||
if( message )
|
if( message )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ public sealed partial class Mod
|
||||||
// Also checks if the directory is available and tries to create it if it is not.
|
// Also checks if the directory is available and tries to create it if it is not.
|
||||||
private void SetBaseDirectory( string newPath, bool firstTime )
|
private void SetBaseDirectory( string newPath, bool firstTime )
|
||||||
{
|
{
|
||||||
if( !firstTime && string.Equals( newPath, Penumbra.Config.ModDirectory, StringComparison.InvariantCultureIgnoreCase ) )
|
if( !firstTime && string.Equals( newPath, Penumbra.Config.ModDirectory, StringComparison.OrdinalIgnoreCase ) )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ public class MainClass : IDalamudPlugin
|
||||||
{
|
{
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
var checkedDirectory = Dalamud.PluginInterface.AssemblyLocation.Directory?.Parent?.Parent?.Name;
|
var checkedDirectory = Dalamud.PluginInterface.AssemblyLocation.Directory?.Parent?.Parent?.Name;
|
||||||
var ret = checkedDirectory?.Equals( "installedPlugins", StringComparison.InvariantCultureIgnoreCase ) ?? false;
|
var ret = checkedDirectory?.Equals( "installedPlugins", StringComparison.OrdinalIgnoreCase ) ?? false;
|
||||||
if (!ret)
|
if (!ret)
|
||||||
PluginLog.Error($"Penumbra is not correctly installed. Application loaded from \"{Dalamud.PluginInterface.AssemblyLocation.Directory!.FullName}\"." );
|
PluginLog.Error($"Penumbra is not correctly installed. Application loaded from \"{Dalamud.PluginInterface.AssemblyLocation.Directory!.FullName}\"." );
|
||||||
return !ret;
|
return !ret;
|
||||||
|
|
@ -310,12 +310,12 @@ public class Penumbra : IDisposable
|
||||||
ShutdownWebServer();
|
ShutdownWebServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SetCollection( string type, string collectionName )
|
public static bool SetCollection( string type, string collectionName )
|
||||||
{
|
{
|
||||||
type = type.ToLowerInvariant();
|
type = type.ToLowerInvariant();
|
||||||
collectionName = collectionName.ToLowerInvariant();
|
collectionName = collectionName.ToLowerInvariant();
|
||||||
|
|
||||||
var collection = string.Equals( collectionName, ModCollection.Empty.Name, StringComparison.InvariantCultureIgnoreCase )
|
var collection = string.Equals( collectionName, ModCollection.Empty.Name, StringComparison.OrdinalIgnoreCase )
|
||||||
? ModCollection.Empty
|
? ModCollection.Empty
|
||||||
: CollectionManager[ collectionName ];
|
: CollectionManager[ collectionName ];
|
||||||
if( collection == null )
|
if( collection == null )
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ public partial class ModEditWindow
|
||||||
private int _folderSkip = 0;
|
private int _folderSkip = 0;
|
||||||
|
|
||||||
private bool CheckFilter( Mod.Editor.FileRegistry registry )
|
private bool CheckFilter( Mod.Editor.FileRegistry registry )
|
||||||
=> _fileFilter.IsEmpty || registry.File.FullName.Contains( _fileFilter.Lower, StringComparison.InvariantCultureIgnoreCase );
|
=> _fileFilter.IsEmpty || registry.File.FullName.Contains( _fileFilter.Lower, StringComparison.OrdinalIgnoreCase );
|
||||||
|
|
||||||
private bool CheckFilter( (Mod.Editor.FileRegistry, int) p )
|
private bool CheckFilter( (Mod.Editor.FileRegistry, int) p )
|
||||||
=> CheckFilter( p.Item1 );
|
=> CheckFilter( p.Item1 );
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
@ -22,7 +21,7 @@ public partial class ModFileSystemSelector
|
||||||
public ColorId Color;
|
public ColorId Color;
|
||||||
}
|
}
|
||||||
|
|
||||||
private const StringComparison IgnoreCase = StringComparison.InvariantCultureIgnoreCase;
|
private const StringComparison IgnoreCase = StringComparison.OrdinalIgnoreCase;
|
||||||
private LowerString _modFilter = LowerString.Empty;
|
private LowerString _modFilter = LowerString.Empty;
|
||||||
private int _filterType = -1;
|
private int _filterType = -1;
|
||||||
private ModFilter _stateFilter = ModFilterExtensions.UnfilteredStateMods;
|
private ModFilter _stateFilter = ModFilterExtensions.UnfilteredStateMods;
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ public partial class ConfigWindow
|
||||||
bool FilterChangedItem( KeyValuePair< string, (SingleArray< IMod >, object?) > item )
|
bool FilterChangedItem( KeyValuePair< string, (SingleArray< IMod >, object?) > item )
|
||||||
=> ( _changedItemFilter.IsEmpty
|
=> ( _changedItemFilter.IsEmpty
|
||||||
|| ChangedItemName( item.Key, item.Value.Item2 )
|
|| ChangedItemName( item.Key, item.Value.Item2 )
|
||||||
.Contains( _changedItemFilter.Lower, StringComparison.InvariantCultureIgnoreCase ) )
|
.Contains( _changedItemFilter.Lower, StringComparison.OrdinalIgnoreCase ) )
|
||||||
&& ( _changedItemModFilter.IsEmpty || item.Value.Item1.Any( m => m.Name.Contains( _changedItemModFilter ) ) );
|
&& ( _changedItemModFilter.IsEmpty || item.Value.Item1.Any( m => m.Name.Contains( _changedItemModFilter ) ) );
|
||||||
|
|
||||||
void DrawChangedItemColumn( KeyValuePair< string, (SingleArray< IMod >, object?) > item )
|
void DrawChangedItemColumn( KeyValuePair< string, (SingleArray< IMod >, object?) > item )
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ public partial class ConfigWindow
|
||||||
{
|
{
|
||||||
// Filter unwanted names.
|
// Filter unwanted names.
|
||||||
if( _resourceManagerFilter.Length != 0
|
if( _resourceManagerFilter.Length != 0
|
||||||
&& !r->FileName.ToString().Contains( _resourceManagerFilter, StringComparison.InvariantCultureIgnoreCase ) )
|
&& !r->FileName.ToString().Contains( _resourceManagerFilter, StringComparison.OrdinalIgnoreCase ) )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue