Skip to content

Commit 96edc48

Browse files
committed
Define componentId's as static readonly array's
1 parent a531a2d commit 96edc48

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ internal sealed unsafe class JpegEncoderCore : IImageEncoderInternals
3333
/// </summary>
3434
private readonly byte[] buffer = new byte[20];
3535

36+
/// <summary>
37+
/// The default component id's.
38+
/// </summary>
39+
private static readonly byte[] DefaultComponentIds = { 1, 2, 3 };
40+
41+
/// <summary>
42+
/// Component id's for RGB colorspace.
43+
/// </summary>
44+
private static readonly byte[] RgbComponentIds = { 82, 71, 66 };
45+
3646
/// <summary>
3747
/// The quality, that will be used to encode the image.
3848
/// </summary>
@@ -148,10 +158,10 @@ private byte[] GetComponentIds()
148158
{
149159
if (this.colorType == JpegColorType.Rgb)
150160
{
151-
return new byte[] { 82, 71, 66 };
161+
return RgbComponentIds;
152162
}
153163

154-
return new byte[] { 1, 2, 3 };
164+
return DefaultComponentIds;
155165
}
156166

157167
/// <summary>

0 commit comments

Comments
 (0)