diff --git a/MetadataExtractor/Formats/Bmp/BmpReader.cs b/MetadataExtractor/Formats/Bmp/BmpReader.cs index d22126c1f..dff15a041 100644 --- a/MetadataExtractor/Formats/Bmp/BmpReader.cs +++ b/MetadataExtractor/Formats/Bmp/BmpReader.cs @@ -354,8 +354,8 @@ private static void ReadBitmapHeader(SequentialReader reader, BmpHeaderDirectory else { using var iccBuffer = profileSize <= 256 - ? new BufferScope(stackalloc byte[profileSize]) - : new BufferScope(profileSize); + ? new ScopedBuffer(stackalloc byte[profileSize]) + : new ScopedBuffer(profileSize); reader.GetBytes(iccBuffer.Span); diff --git a/MetadataExtractor/Formats/Exif/ExifTiffHandler.cs b/MetadataExtractor/Formats/Exif/ExifTiffHandler.cs index 30839deea..2969664d6 100644 --- a/MetadataExtractor/Formats/Exif/ExifTiffHandler.cs +++ b/MetadataExtractor/Formats/Exif/ExifTiffHandler.cs @@ -180,7 +180,7 @@ public override bool CustomProcessTag(in TiffReaderContext context, int tagId, i // Custom processing for ICC Profile data if (tagId == ExifDirectoryBase.TagInterColorProfile) { - using var iccBuffer = new BufferScope(byteCount); + using var iccBuffer = new ScopedBuffer(byteCount); context.Reader.GetBytes(valueOffset, iccBuffer.Span); var iccDirectory = new IccReader().Extract(iccBuffer.Span); iccDirectory.Parent = CurrentDirectory; diff --git a/MetadataExtractor/Formats/Photoshop/PhotoshopTiffHandler.cs b/MetadataExtractor/Formats/Photoshop/PhotoshopTiffHandler.cs index 09081ee32..f85103fb5 100644 --- a/MetadataExtractor/Formats/Photoshop/PhotoshopTiffHandler.cs +++ b/MetadataExtractor/Formats/Photoshop/PhotoshopTiffHandler.cs @@ -34,7 +34,7 @@ public override bool CustomProcessTag(in TiffReaderContext context, int tagId, i return true; case TagIccProfiles: { - using var bufferScope = new BufferScope(byteCount); + using var bufferScope = new ScopedBuffer(byteCount); context.Reader.GetBytes(valueOffset, bufferScope.Span); Directories.Add(new IccReader().Extract(bufferScope.Span)); return true; diff --git a/MetadataExtractor/IO/BufferReader.Indexed.cs b/MetadataExtractor/IO/BufferReader.Indexed.cs index 994bec65f..974651fb3 100644 --- a/MetadataExtractor/IO/BufferReader.Indexed.cs +++ b/MetadataExtractor/IO/BufferReader.Indexed.cs @@ -195,7 +195,7 @@ public readonly string GetString(int index, int bytesRequested, Encoding encodin } else { - using var buffer = new BufferScope(bytesRequested); + using var buffer = new ScopedBuffer(bytesRequested); GetBytes(index, buffer.Span); diff --git a/MetadataExtractor/IO/BufferReader.Sequential.cs b/MetadataExtractor/IO/BufferReader.Sequential.cs index bc3d545f6..1d707c318 100644 --- a/MetadataExtractor/IO/BufferReader.Sequential.cs +++ b/MetadataExtractor/IO/BufferReader.Sequential.cs @@ -126,9 +126,9 @@ public string GetString(int bytesRequested, Encoding encoding) if (bytesRequested is 0) return ""; - using BufferScope bytes = bytesRequested <= 256 - ? new BufferScope(stackalloc byte[bytesRequested]) - : new BufferScope(bytesRequested); + using ScopedBuffer bytes = bytesRequested <= 256 + ? new ScopedBuffer(stackalloc byte[bytesRequested]) + : new ScopedBuffer(bytesRequested); GetBytes(bytes.Span); diff --git a/MetadataExtractor/IO/BufferScope.cs b/MetadataExtractor/IO/ScopedBuffer.cs similarity index 86% rename from MetadataExtractor/IO/BufferScope.cs rename to MetadataExtractor/IO/ScopedBuffer.cs index e733c4cf8..ebbb0d5b5 100644 --- a/MetadataExtractor/IO/BufferScope.cs +++ b/MetadataExtractor/IO/ScopedBuffer.cs @@ -4,18 +4,18 @@ namespace MetadataExtractor.IO; -internal ref struct BufferScope +internal ref struct ScopedBuffer { private byte[]? _rentedBuffer; private readonly Span _span; - public BufferScope(int size) + public ScopedBuffer(int size) { _rentedBuffer = ArrayPool.Shared.Rent(size); _span = _rentedBuffer.AsSpan(0, size); } - public BufferScope(Span span) + public ScopedBuffer(Span span) { _span = span; }