From d670edcccf25f1778ed61730d2d888153b45c714 Mon Sep 17 00:00:00 2001 From: Ildar Khayrutdinov Date: Sat, 2 Oct 2021 10:59:46 +0300 Subject: [PATCH] build fixes, minor improves --- .../Profiles/Exif/Values/ExifLong8Array.cs | 15 +++++++-------- .../Profiles/Exif/Values/ExifNumberArray.cs | 4 ++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifLong8Array.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifLong8Array.cs index d76deba076..618135e926 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifLong8Array.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifLong8Array.cs @@ -1,6 +1,8 @@ // Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. +using System.Runtime.CompilerServices; + namespace SixLabors.ImageSharp.Metadata.Profiles.Exif { internal sealed class ExifLong8Array : ExifArrayValue @@ -29,9 +31,9 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif return ExifDataType.Long; } - for (int i = 0; i < this.Value.Length; i++) + foreach (ulong value in this.Value) { - if (this.Value[i] > uint.MaxValue) + if (value > uint.MaxValue) { return ExifDataType.Long8; } @@ -64,7 +66,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif case long[] array: { - if (value.GetType().Equals(typeof(ulong[]))) + if (value.GetType() == typeof(ulong[])) { return this.SetArray((ulong[])value); } @@ -74,7 +76,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif case int[] array: { - if (value.GetType().Equals(typeof(uint[]))) + if (value.GetType() == typeof(uint[])) { return this.SetArray((uint[])value); } @@ -84,7 +86,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif case short[] array: { - if (value.GetType().Equals(typeof(ushort[]))) + if (value.GetType() == typeof(ushort[])) { return this.SetArray((ushort[])value); } @@ -106,10 +108,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif private bool SetArray(long[] values) { - var numbers = new ulong[values.Length]; this.Value = Unsafe.As(ref values); - - this.Value = numbers; return true; } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifNumberArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifNumberArray.cs index c65e0b4608..2d006c5388 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifNumberArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifNumberArray.cs @@ -24,9 +24,9 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif return ExifDataType.Short; } - for (int i = 0; i < this.Value.Length; i++) + foreach (Number value in this.Value) { - if (this.Value[i] > ushort.MaxValue) + if (value > ushort.MaxValue) { return ExifDataType.Long; }