From 3acd97cdfe4747eac07da5a4509d7ce523d90208 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Wed, 18 Apr 2018 11:57:58 -0700 Subject: [PATCH] Pass metadata directly to WriteComments to avoid unnessary codegen. --- src/ImageSharp/Formats/Gif/GifEncoderCore.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs index cf06cc1e02..20850cfc25 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs @@ -87,7 +87,7 @@ namespace SixLabors.ImageSharp.Formats.Gif this.WriteLogicalScreenDescriptor(image, stream, index); // Write the first frame. - this.WriteComments(image, stream); + this.WriteComments(image.MetaData, stream); // Write additional frames. if (image.Frames.Count > 1) @@ -212,18 +212,16 @@ namespace SixLabors.ImageSharp.Formats.Gif /// /// Writes the image comments to the stream. /// - /// The pixel format. - /// The to be encoded. + /// The metadata to be extract the comment data. /// The stream to write to. - private void WriteComments(Image image, Stream stream) - where TPixel : struct, IPixel + private void WriteComments(ImageMetaData metadata, Stream stream) { if (this.ignoreMetadata) { return; } - - ImageProperty property = image.MetaData.Properties.FirstOrDefault(p => p.Name == GifConstants.Comments); + + ImageProperty property = metadata.Properties.FirstOrDefault(p => p.Name == GifConstants.Comments); if (property == null || string.IsNullOrEmpty(property.Value)) { return;