Optimize string comparison
This commit is contained in:
committed by
atlimit8
parent
c0d270b87d
commit
cae43808d9
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
|
||||
void CheckInheritance(Action<string> emitError, string actor, Dictionary<string, List<string>> inheritsMap)
|
||||
{
|
||||
var toResolve = new Queue<string>(inheritsMap.Keys.Where(k => k.ToLowerInvariant() == actor.ToLowerInvariant()));
|
||||
var toResolve = new Queue<string>(inheritsMap.Keys.Where(k => string.Equals(k, actor, StringComparison.InvariantCultureIgnoreCase)));
|
||||
while (toResolve.TryDequeue(out var key))
|
||||
{
|
||||
// Missing keys are a fatal merge error, so will have already been reported by other lint checks
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public void LoadPalettes(WorldRenderer wr)
|
||||
{
|
||||
if (info.Tileset == null || info.Tileset.ToLowerInvariant() == world.Map.Tileset.ToLowerInvariant())
|
||||
if (info.Tileset == null || string.Equals(info.Tileset, world.Map.Tileset, StringComparison.InvariantCultureIgnoreCase))
|
||||
wr.AddPalette(info.Name, ((IProvidesCursorPaletteInfo)info).ReadPalette(world.Map), info.AllowModifiers);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public void LoadPalettes(WorldRenderer wr)
|
||||
{
|
||||
if (info.Tileset != null && info.Tileset.ToLowerInvariant() != world.Map.Tileset.ToLowerInvariant())
|
||||
if (info.Tileset != null && !string.Equals(info.Tileset, world.Map.Tileset, StringComparison.InvariantCultureIgnoreCase))
|
||||
return;
|
||||
|
||||
wr.AddPalette(info.Name, ((IProvidesCursorPaletteInfo)info).ReadPalette(world.Map), info.AllowModifiers);
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public void LoadPalettes(WorldRenderer wr)
|
||||
{
|
||||
// Enable palette only for a specific tileset
|
||||
if (info.Tileset != null && info.Tileset.ToLowerInvariant() != world.Map.Tileset.ToLowerInvariant())
|
||||
if (info.Tileset != null && !string.Equals(info.Tileset, world.Map.Tileset, System.StringComparison.InvariantCultureIgnoreCase))
|
||||
return;
|
||||
|
||||
var a = info.A / 255f;
|
||||
|
||||
@@ -31,9 +31,9 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
if (value == null)
|
||||
continue;
|
||||
|
||||
if (value.ToLowerInvariant() == "yes")
|
||||
if (string.Equals(value, "yes", System.StringComparison.InvariantCultureIgnoreCase))
|
||||
n.ReplaceValue("true");
|
||||
else if (value.ToLowerInvariant() == "no")
|
||||
else if (string.Equals(value, "no", System.StringComparison.InvariantCultureIgnoreCase))
|
||||
n.ReplaceValue("false");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,7 +389,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
try
|
||||
{
|
||||
var parts = s.Value.Split(',');
|
||||
if (parts[0] == "")
|
||||
if (string.IsNullOrEmpty(parts[0]))
|
||||
parts[0] = "Neutral";
|
||||
|
||||
if (!players.Contains(parts[0]))
|
||||
|
||||
Reference in New Issue
Block a user