Remove allocations in 'GetForFilename'

このコミットが含まれているのは:
Sergio Pedri committed 2024-08-28 00:25:47 -07:00
1 親 e7db1d3340
コミット 3970ef1e3a
2ファイル変更
+10 -1

検索条件に一致するファイルはありません

+7 -1
ファイルの表示
@@ -111,7 +111,13 @@ internal static class WICFormatHelper
/// <exception cref="ArgumentException">Thrown when the input filename doesn't have a valid file extension.</exception>
public static Guid GetForFilename(ReadOnlySpan<char> filename)
{
return Path.GetExtension(filename).ToString().ToLowerInvariant() switch
Span<char> extension = stackalloc char[4];
int length = Path.GetExtension(filename).ToLowerInvariant(extension);
default(ArgumentException).ThrowIf(length == -1, nameof(filename));
return extension[..length] switch
{
".dib" or
".rle" or
+3
ファイルの表示
@@ -358,6 +358,7 @@ internal sealed unsafe class WICHelper
where T : unmanaged
{
using ComPtr<IWICBitmapEncoder> wicBitmapEncoder = default;
Guid containerGuid = WICFormatHelper.GetForFilename(filename);
// Create the image encoder
@@ -397,6 +398,7 @@ internal sealed unsafe class WICHelper
where T : unmanaged
{
using ComPtr<IWICBitmapEncoder> wicBitmapEncoder = default;
Guid containerGuid = WICFormatHelper.GetForFormat(format);
// Create the image encoder
@@ -431,6 +433,7 @@ internal sealed unsafe class WICHelper
where T : unmanaged
{
using ComPtr<IWICBitmapEncoder> wicBitmapEncoder = default;
Guid containerGuid = WICFormatHelper.GetForFormat(format);
// Create the image encoder