Make string comparison ordinal, add comment

This commit is contained in:
Matt Nadareski
2025-01-07 20:13:58 -05:00
parent f918b7ab79
commit 49aa18bccd

View File

@@ -162,7 +162,9 @@ namespace SabreTools.DatItems
if (GetName() == other?.GetName())
return Equals(other) ? 0 : 1;
return string.Compare(GetName(), other?.GetName());
// If `other?.GetName()` is null, Compare will return > 0
// If `this.GetName()` is null, Compare will return < 0
return string.Compare(GetName(), other?.GetName(), StringComparison.Ordinal);
}
catch
{
@@ -548,7 +550,9 @@ namespace SabreTools.DatItems
if (GetName() == other?.GetName())
return Equals(other) ? 0 : 1;
return string.Compare(GetName(), other?.GetName());
// If `other?.GetName()` is null, Compare will return > 0
// If `this.GetName()` is null, Compare will return < 0
return string.Compare(GetName(), other?.GetName(), StringComparison.Ordinal);
}
catch
{