Browse Source

Initialize values during declaration

pull/2330/head
Stefan Nikolei 3 years ago
parent
commit
6eec48de54
  1. 12
      src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs

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

@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Iptc;
/// </summary>
public sealed class IptcProfile : IDeepCloneable<IptcProfile>
{
private Collection<IptcValue> values;
private readonly Collection<IptcValue> values = new();
private const byte IptcTagMarkerByte = 0x1c;
@ -53,8 +53,6 @@ public sealed class IptcProfile : IDeepCloneable<IptcProfile>
{
Guard.NotNull(other, nameof(other));
this.values = new Collection<IptcValue>();
foreach (IptcValue value in other.Values)
{
this.values.Add(value.DeepClone());
@ -307,16 +305,8 @@ public sealed class IptcProfile : IDeepCloneable<IptcProfile>
return offset;
}
[MemberNotNull(nameof(values))]
private void Initialize()
{
if (this.values != null)
{
return;
}
this.values = new Collection<IptcValue>();
if (this.Data == null || this.Data[0] != IptcTagMarkerByte)
{
return;

Loading…
Cancel
Save