Skip to content

Commit

Permalink
Rename BufferScope -> ScopedBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
iamcarbon committed Feb 19, 2024
1 parent dd06d8a commit 51ff3ee
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions MetadataExtractor/Formats/Bmp/BmpReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion MetadataExtractor/Formats/Exif/ExifTiffHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion MetadataExtractor/IO/BufferReader.Indexed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions MetadataExtractor/IO/BufferReader.Sequential.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@

namespace MetadataExtractor.IO;

internal ref struct BufferScope
internal ref struct ScopedBuffer
{
private byte[]? _rentedBuffer;
private readonly Span<byte> _span;

public BufferScope(int size)
public ScopedBuffer(int size)
{
_rentedBuffer = ArrayPool<byte>.Shared.Rent(size);
_span = _rentedBuffer.AsSpan(0, size);
}

public BufferScope(Span<byte> span)
public ScopedBuffer(Span<byte> span)
{
_span = span;
}
Expand Down

0 comments on commit 51ff3ee

Please sign in to comment.