Reduce allocations, simplifed code, faster implementation, included tests - StreamInfo.ToUrl (#9369)

* Rework PR 6168

* Fix test
This commit is contained in:
Tim Eisele
2025-03-28 13:51:44 +01:00
committed by GitHub
parent cb931e0062
commit 9657708b38
8 changed files with 735 additions and 171 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Jellyfin.Extensions;
@@ -55,4 +56,22 @@ public static class EnumerableExtensions
{
yield return item;
}
/// <summary>
/// Gets an IEnumerable consisting of all flags of an enum.
/// </summary>
/// <param name="flags">The flags enum.</param>
/// <typeparam name="T">The type of item.</typeparam>
/// <returns>The IEnumerable{Enum}.</returns>
public static IEnumerable<T> GetUniqueFlags<T>(this T flags)
where T : Enum
{
foreach (Enum value in Enum.GetValues(flags.GetType()))
{
if (flags.HasFlag(value))
{
yield return (T)value;
}
}
}
}