Optimize string comparison
This commit is contained in:
committed by
atlimit8
parent
c0d270b87d
commit
cae43808d9
@@ -137,8 +137,8 @@ namespace OpenRA
|
|||||||
sources = sources.Append(RuleDefinitions.Nodes.Where(IsLoadableRuleDefinition).ToList());
|
sources = sources.Append(RuleDefinitions.Nodes.Where(IsLoadableRuleDefinition).ToList());
|
||||||
|
|
||||||
var yamlNodes = MiniYaml.Merge(sources);
|
var yamlNodes = MiniYaml.Merge(sources);
|
||||||
WorldActorInfo = new ActorInfo(modData.ObjectCreator, "world", yamlNodes.First(n => n.Key.ToLowerInvariant() == "world").Value);
|
WorldActorInfo = new ActorInfo(modData.ObjectCreator, "world", yamlNodes.First(n => string.Equals(n.Key, "world", StringComparison.InvariantCultureIgnoreCase)).Value);
|
||||||
PlayerActorInfo = new ActorInfo(modData.ObjectCreator, "player", yamlNodes.First(n => n.Key.ToLowerInvariant() == "player").Value);
|
PlayerActorInfo = new ActorInfo(modData.ObjectCreator, "player", yamlNodes.First(n => string.Equals(n.Key, "player", StringComparison.InvariantCultureIgnoreCase)).Value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
|
|
||||||
void CheckInheritance(Action<string> emitError, string actor, Dictionary<string, List<string>> inheritsMap)
|
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))
|
while (toResolve.TryDequeue(out var key))
|
||||||
{
|
{
|
||||||
// Missing keys are a fatal merge error, so will have already been reported by other lint checks
|
// 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)
|
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);
|
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)
|
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;
|
return;
|
||||||
|
|
||||||
wr.AddPalette(info.Name, ((IProvidesCursorPaletteInfo)info).ReadPalette(world.Map), info.AllowModifiers);
|
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)
|
public void LoadPalettes(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
// Enable palette only for a specific tileset
|
// 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;
|
return;
|
||||||
|
|
||||||
var a = info.A / 255f;
|
var a = info.A / 255f;
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
|||||||
if (value == null)
|
if (value == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (value.ToLowerInvariant() == "yes")
|
if (string.Equals(value, "yes", System.StringComparison.InvariantCultureIgnoreCase))
|
||||||
n.ReplaceValue("true");
|
n.ReplaceValue("true");
|
||||||
else if (value.ToLowerInvariant() == "no")
|
else if (string.Equals(value, "no", System.StringComparison.InvariantCultureIgnoreCase))
|
||||||
n.ReplaceValue("false");
|
n.ReplaceValue("false");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -389,7 +389,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var parts = s.Value.Split(',');
|
var parts = s.Value.Split(',');
|
||||||
if (parts[0] == "")
|
if (string.IsNullOrEmpty(parts[0]))
|
||||||
parts[0] = "Neutral";
|
parts[0] = "Neutral";
|
||||||
|
|
||||||
if (!players.Contains(parts[0]))
|
if (!players.Contains(parts[0]))
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ namespace OpenRA.Mods.D2k.UtilityCommands
|
|||||||
tileSetsFromYaml = terrainInfo.Templates.Where(t =>
|
tileSetsFromYaml = terrainInfo.Templates.Where(t =>
|
||||||
{
|
{
|
||||||
var templateInfo = (DefaultTerrainTemplateInfo)t.Value;
|
var templateInfo = (DefaultTerrainTemplateInfo)t.Value;
|
||||||
return templateInfo.Frames != null && templateInfo.Images[0].ToLowerInvariant() == tilesetName.ToLowerInvariant();
|
return templateInfo.Frames != null && string.Equals(templateInfo.Images[0], tilesetName, StringComparison.InvariantCultureIgnoreCase);
|
||||||
}).Select(ts => ts.Value).ToList();
|
}).Select(ts => ts.Value).ToList();
|
||||||
|
|
||||||
var players = new MapPlayers(map.Rules, playerCount);
|
var players = new MapPlayers(map.Rules, playerCount);
|
||||||
@@ -416,7 +416,7 @@ namespace OpenRA.Mods.D2k.UtilityCommands
|
|||||||
TerrainTile GetTile(int tileIndex)
|
TerrainTile GetTile(int tileIndex)
|
||||||
{
|
{
|
||||||
// Some tiles are duplicates of other tiles, just on a different tileset
|
// Some tiles are duplicates of other tiles, just on a different tileset
|
||||||
if (tilesetName.ToLowerInvariant() == "bloxbgbs.r8")
|
if (string.Equals(tilesetName, "bloxbgbs.r8", StringComparison.InvariantCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
if (tileIndex == 355)
|
if (tileIndex == 355)
|
||||||
return new TerrainTile(441, 0);
|
return new TerrainTile(441, 0);
|
||||||
@@ -425,7 +425,7 @@ namespace OpenRA.Mods.D2k.UtilityCommands
|
|||||||
return new TerrainTile(442, 0);
|
return new TerrainTile(442, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tilesetName.ToLowerInvariant() == "bloxtree.r8")
|
if (string.Equals(tilesetName, "bloxtree.r8", StringComparison.InvariantCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
var indices = new[] { 683, 684, 685, 706, 703, 704, 705, 726, 723, 724, 725, 746, 743, 744, 745, 747 };
|
var indices = new[] { 683, 684, 685, 706, 703, 704, 705, 726, 723, 724, 725, 746, 743, 744, 745, 747 };
|
||||||
for (var i = 0; i < 16; i++)
|
for (var i = 0; i < 16; i++)
|
||||||
@@ -446,7 +446,7 @@ namespace OpenRA.Mods.D2k.UtilityCommands
|
|||||||
return new TerrainTile(215, 0);
|
return new TerrainTile(215, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tilesetName.ToLowerInvariant() == "bloxwast.r8")
|
if (string.Equals(tilesetName, "bloxwast.r8", StringComparison.InvariantCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
if (tileIndex == 342)
|
if (tileIndex == 342)
|
||||||
return new TerrainTile(250, 0);
|
return new TerrainTile(250, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user