Browse Source

Remove allocation and clean up docs

pull/1174/head
James Jackson-South 6 years ago
parent
commit
7fb1612c30
  1. 5
      src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs
  2. 2
      src/ImageSharp/Metadata/Profiles/IPTC/IptcTag.cs
  3. 18
      src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs

5
src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs

@ -10,11 +10,8 @@ using System.Text;
namespace SixLabors.ImageSharp.Metadata.Profiles.Iptc namespace SixLabors.ImageSharp.Metadata.Profiles.Iptc
{ {
/// <summary> /// <summary>
/// Class that can be used to access an Iptc profile. /// Represents an IPTC profile providing access to the collection of values.
/// </summary> /// </summary>
/// <remarks>This source code is from the Magick.Net project:
/// https://github.com/dlemstra/Magick.NET/tree/master/src/Magick.NET/Shared/Profiles/Iptc/IptcProfile.cs
/// </remarks>
public sealed class IptcProfile : IDeepCloneable<IptcProfile> public sealed class IptcProfile : IDeepCloneable<IptcProfile>
{ {
private Collection<IptcValue> values; private Collection<IptcValue> values;

2
src/ImageSharp/Metadata/Profiles/IPTC/IptcTag.cs

@ -4,7 +4,7 @@
namespace SixLabors.ImageSharp.Metadata.Profiles.Iptc namespace SixLabors.ImageSharp.Metadata.Profiles.Iptc
{ {
/// <summary> /// <summary>
/// All iptc tags relevant for images. /// Provides enumeration of all IPTC tags relevant for images.
/// </summary> /// </summary>
public enum IptcTag public enum IptcTag
{ {

18
src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs

@ -7,11 +7,11 @@ using System.Text;
namespace SixLabors.ImageSharp.Metadata.Profiles.Iptc namespace SixLabors.ImageSharp.Metadata.Profiles.Iptc
{ {
/// <summary> /// <summary>
/// A value of the iptc profile. /// Represents a single value of the IPTC profile.
/// </summary> /// </summary>
public sealed class IptcValue : IDeepCloneable<IptcValue> public sealed class IptcValue : IDeepCloneable<IptcValue>
{ {
private byte[] data; private byte[] data = Array.Empty<byte>();
private Encoding encoding; private Encoding encoding;
internal IptcValue(IptcValue other) internal IptcValue(IptcValue other)
@ -165,16 +165,14 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Iptc
return false; return false;
} }
byte[] data = other.ToByteArray(); if (this.data.Length != other.data.Length)
if (this.data.Length != data.Length)
{ {
return false; return false;
} }
for (int i = 0; i < this.data.Length; i++) for (int i = 0; i < this.data.Length; i++)
{ {
if (this.data[i] != data[i]) if (this.data[i] != other.data[i])
{ {
return false; return false;
} }
@ -209,13 +207,13 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Iptc
/// <summary> /// <summary>
/// Returns a string that represents the current value with the specified encoding. /// Returns a string that represents the current value with the specified encoding.
/// </summary> /// </summary>
/// <param name="enc">The encoding to use.</param> /// <param name="encoding">The encoding to use.</param>
/// <returns>A string that represents the current value with the specified encoding.</returns> /// <returns>A string that represents the current value with the specified encoding.</returns>
public string ToString(Encoding enc) public string ToString(Encoding encoding)
{ {
Guard.NotNull(enc, nameof(enc)); Guard.NotNull(encoding, nameof(encoding));
return enc.GetString(this.data); return encoding.GetString(this.data);
} }
} }
} }

Loading…
Cancel
Save