From a8812d7aa50ab751c7473340f5ae02ba660228ca Mon Sep 17 00:00:00 2001 From: Peter Amrehn Date: Sun, 4 Nov 2018 15:04:42 +0100 Subject: [PATCH] unwrap for-loop to avoid conditional check inside it is known beforehand when the if condition inside the loop will not match: only in the last iteration. Thus we can loop once less and append the last element afterwards. --- src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs index 2be5addc2..81393342d 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs @@ -543,15 +543,14 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components { var sb = new StringBuilder(); sb.Append('['); - for (int i = 0; i < Size; i++) + for (int i = 0; i < Size - 1; i++) { sb.Append(this[i]); - if (i < Size - 1) - { - sb.Append(','); - } + sb.Append(','); } + sb.Append(this[Size - 1]); + sb.Append(']'); return sb.ToString(); }