Browse Source

fix allocation (CA2014)

pull/2869/head
Ildar Khayrutdinov 1 year ago
parent
commit
40b7be8041
  1. 6
      src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs

6
src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs

@ -191,10 +191,7 @@ internal abstract class BaseExifReader
{ {
do do
{ {
int sz = this.subIfds.Count; ulong[] buf = [.. this.subIfds];
Span<ulong> buf = sz <= 256 ? stackalloc ulong[sz] : new ulong[sz];
this.subIfds.CopyTo(buf);
this.subIfds.Clear(); this.subIfds.Clear();
foreach (ulong subIfdOffset in buf) foreach (ulong subIfdOffset in buf)
{ {
@ -456,6 +453,7 @@ internal abstract class BaseExifReader
ExifTagValue.TileByteCounts => new ExifLong8Array(ExifTagValue.TileByteCounts), ExifTagValue.TileByteCounts => new ExifLong8Array(ExifTagValue.TileByteCounts),
_ => ExifValues.Create(tag) ?? ExifValues.Create(tag, dataType, numberOfComponents), _ => ExifValues.Create(tag) ?? ExifValues.Create(tag, dataType, numberOfComponents),
}; };
if (exifValue is null) if (exifValue is null)
{ {
this.AddInvalidTag(new UnkownExifTag(tag)); this.AddInvalidTag(new UnkownExifTag(tag));

Loading…
Cancel
Save