Skip to content

Commit 909e06b

Browse files
committed
Revert "Pin the refs for faster access"
1 parent b240679 commit 909e06b

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

src/ImageSharp/Formats/Webp/Lossless/Vp8LBackwardRefs.cs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,21 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless;
88

99
internal class Vp8LBackwardRefs : IDisposable
1010
{
11-
private readonly IMemoryOwner<PixOrCopy> owner;
12-
private readonly MemoryHandle handle;
11+
private readonly IMemoryOwner<PixOrCopy> refs;
1312
private int count;
1413

1514
public Vp8LBackwardRefs(MemoryAllocator memoryAllocator, int pixels)
1615
{
17-
this.owner = memoryAllocator.Allocate<PixOrCopy>(pixels);
18-
this.handle = this.owner.Memory.Pin();
16+
this.refs = memoryAllocator.Allocate<PixOrCopy>(pixels);
1917
this.count = 0;
2018
}
2119

22-
public void Add(PixOrCopy pixOrCopy)
23-
{
24-
unsafe
25-
{
26-
((PixOrCopy*)this.handle.Pointer)[this.count++] = pixOrCopy;
27-
}
28-
}
20+
public void Add(PixOrCopy pixOrCopy) => this.refs.Memory.Span[this.count++] = pixOrCopy;
2921

3022
public void Clear() => this.count = 0;
3123

32-
public Span<PixOrCopy>.Enumerator GetEnumerator() => this.owner.Slice(0, this.count).GetEnumerator();
24+
public Span<PixOrCopy>.Enumerator GetEnumerator() => this.refs.Slice(0, this.count).GetEnumerator();
3325

3426
/// <inheritdoc/>
35-
public void Dispose()
36-
{
37-
this.handle.Dispose();
38-
this.owner.Dispose();
39-
}
27+
public void Dispose() => this.refs.Dispose();
4028
}

0 commit comments

Comments
 (0)