Browse Source

Improved codegen for throw path in MemoryGroup<T>.Owned

pull/1574/head
Sergio Pedri 6 years ago
parent
commit
b7a900bc18
  1. 12
      src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Owned.cs

12
src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Owned.cs

@ -5,6 +5,7 @@ using System;
using System.Buffers; using System.Buffers;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices;
namespace SixLabors.ImageSharp.Memory namespace SixLabors.ImageSharp.Memory
{ {
@ -69,14 +70,21 @@ namespace SixLabors.ImageSharp.Memory
this.IsValid = false; this.IsValid = false;
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void EnsureNotDisposed() private void EnsureNotDisposed()
{ {
if (this.memoryOwners == null) if (this.memoryOwners is null)
{ {
throw new ObjectDisposedException(nameof(MemoryGroup<T>)); ThrowObjectDisposedException();
} }
} }
[MethodImpl(MethodImplOptions.NoInlining)]
private static void ThrowObjectDisposedException()
{
throw new ObjectDisposedException(nameof(MemoryGroup<T>));
}
internal static void SwapContents(Owned a, Owned b) internal static void SwapContents(Owned a, Owned b)
{ {
a.EnsureNotDisposed(); a.EnsureNotDisposed();

Loading…
Cancel
Save