Avoid delegate allocation in RotationPaletteEffect.
Use a loop to perform the same check instead.
This commit is contained in:
@@ -92,8 +92,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
foreach (var kvp in palettes)
|
||||
{
|
||||
if ((info.Palettes.Count > 0 && !info.Palettes.Any(kvp.Key.StartsWith))
|
||||
|| (info.ExcludePalettes.Count > 0 && info.ExcludePalettes.Any(kvp.Key.StartsWith)))
|
||||
if ((info.Palettes.Count > 0 && !AnyPaletteNameStartsWith(info.Palettes, kvp.Key))
|
||||
|| (info.ExcludePalettes.Count > 0 && AnyPaletteNameStartsWith(info.ExcludePalettes, kvp.Key)))
|
||||
continue;
|
||||
|
||||
var palette = kvp.Value;
|
||||
@@ -105,5 +105,15 @@ namespace OpenRA.Mods.Common.Traits
|
||||
palette[info.RotationBase + i] = rotationBuffer[i];
|
||||
}
|
||||
}
|
||||
|
||||
static bool AnyPaletteNameStartsWith(HashSet<string> names, string prefix)
|
||||
{
|
||||
// PERF: Avoid LINQ.
|
||||
foreach (var name in names)
|
||||
if (name.StartsWith(prefix))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user