diff --git a/OpenRA.Mods.Common/Traits/PaletteEffects/RotationPaletteEffect.cs b/OpenRA.Mods.Common/Traits/PaletteEffects/RotationPaletteEffect.cs index 21ba9a0419..258f89f358 100644 --- a/OpenRA.Mods.Common/Traits/PaletteEffects/RotationPaletteEffect.cs +++ b/OpenRA.Mods.Common/Traits/PaletteEffects/RotationPaletteEffect.cs @@ -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 names, string prefix) + { + // PERF: Avoid LINQ. + foreach (var name in names) + if (name.StartsWith(prefix)) + return true; + + return false; + } } }