mirror of https://github.com/jellyfin/jellyfin
optimize GetUniqueFlags()
This commit is contained in:
parent
d70e0fe9cf
commit
ef73ed6ef7
|
|
@ -64,13 +64,13 @@ public static class EnumerableExtensions
|
||||||
/// <typeparam name="T">The type of item.</typeparam>
|
/// <typeparam name="T">The type of item.</typeparam>
|
||||||
/// <returns>The IEnumerable{Enum}.</returns>
|
/// <returns>The IEnumerable{Enum}.</returns>
|
||||||
public static IEnumerable<T> GetUniqueFlags<T>(this T flags)
|
public static IEnumerable<T> GetUniqueFlags<T>(this T flags)
|
||||||
where T : Enum
|
where T : struct, Enum
|
||||||
{
|
{
|
||||||
foreach (Enum value in Enum.GetValues(flags.GetType()))
|
foreach (T value in Enum.GetValues<T>())
|
||||||
{
|
{
|
||||||
if (flags.HasFlag(value))
|
if (flags.HasFlag(value))
|
||||||
{
|
{
|
||||||
yield return (T)value;
|
yield return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue