diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs index 3f603fddfe..210f0b5e5b 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs @@ -709,13 +709,15 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc // Jump over position table long tablePosition = this.dataStream.Position; this.dataStream.Position += length * 8; - IccPositionNumber[] table = new IccPositionNumber[length]; + var table = new IccPositionNumber[length]; for (int i = 0; i < length; i++) { + ref IccProfileSequenceIdentifier sequenceIdentifier = ref value.Data[i]; + uint offset = (uint)(this.dataStream.Position - start); - int size = this.WriteProfileId(value.Data[i].Id); - size += this.WriteTagDataEntry(new IccMultiLocalizedUnicodeTagDataEntry(value.Data[i].Description)); + int size = this.WriteProfileId(sequenceIdentifier.Id); + size += this.WriteTagDataEntry(new IccMultiLocalizedUnicodeTagDataEntry(sequenceIdentifier.Description)); size += this.WritePadding(); table[i] = new IccPositionNumber(offset, (uint)size); count += size; diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs index 7ef17d37ec..555fcb202a 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs @@ -41,8 +41,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public override bool Equals(IccTagDataEntry other) { - var entry = other as IccProfileSequenceIdentifierTagDataEntry; - return entry != null && this.Equals(entry); + return other is IccProfileSequenceIdentifierTagDataEntry entry && this.Equals(entry); } /// @@ -74,7 +73,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc return true; } - return obj is IccProfileSequenceIdentifierTagDataEntry && this.Equals((IccProfileSequenceIdentifierTagDataEntry)obj); + return obj is IccProfileSequenceIdentifierTagDataEntry other && this.Equals(other); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs index 3e63679044..63dd0cfc56 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs @@ -7,12 +7,12 @@ using System.Linq; namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { /// - /// Description of a profile within a sequence + /// Description of a profile within a sequence. /// - internal sealed class IccProfileSequenceIdentifier : IEquatable + internal readonly struct IccProfileSequenceIdentifier : IEquatable { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the struct. /// /// ID of the profile /// Description of the profile @@ -25,44 +25,23 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc } /// - /// Gets the ID of the profile + /// Gets the ID of the profile. /// public IccProfileId Id { get; } /// - /// Gets the description of the profile + /// Gets the description of the profile. /// public IccLocalizedString[] Description { get; } /// - public bool Equals(IccProfileSequenceIdentifier other) - { - if (ReferenceEquals(null, other)) - { - return false; - } - - if (ReferenceEquals(this, other)) - { - return true; - } - - return this.Id.Equals(other.Id) && this.Description.SequenceEqual(other.Description); - } + public bool Equals(IccProfileSequenceIdentifier other) => + this.Id.Equals(other.Id) && + this.Description.SequenceEqual(other.Description); /// public override bool Equals(object obj) { - if (obj == null) - { - return false; - } - - if (ReferenceEquals(this, obj)) - { - return true; - } - return obj is IccProfileSequenceIdentifier other && this.Equals(other); }