|
|
@ -171,7 +171,7 @@ namespace SixLabors.ImageSharp.Memory |
|
|
internal Span<T> GetSingleSpan() |
|
|
internal Span<T> GetSingleSpan() |
|
|
{ |
|
|
{ |
|
|
// TODO: If we need a public version of this method, we need to cache the non-fast Memory<T> of this.MemoryGroup
|
|
|
// TODO: If we need a public version of this method, we need to cache the non-fast Memory<T> of this.MemoryGroup
|
|
|
return this.cachedMemory.Length != 0 ? this.cachedMemory.Span : ThrowInvalidOperationSingleSpan(); |
|
|
return this.cachedMemory.Length != 0 ? this.cachedMemory.Span : this.GetSingleSpanSlow(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
@ -186,7 +186,7 @@ namespace SixLabors.ImageSharp.Memory |
|
|
internal Memory<T> GetSingleMemory() |
|
|
internal Memory<T> GetSingleMemory() |
|
|
{ |
|
|
{ |
|
|
// TODO: If we need a public version of this method, we need to cache the non-fast Memory<T> of this.MemoryGroup
|
|
|
// TODO: If we need a public version of this method, we need to cache the non-fast Memory<T> of this.MemoryGroup
|
|
|
return this.cachedMemory.Length != 0 ? this.cachedMemory : ThrowInvalidOperationSingleMemory(); |
|
|
return this.cachedMemory.Length != 0 ? this.cachedMemory : this.GetSingleMemorySlow(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
@ -205,6 +205,9 @@ namespace SixLabors.ImageSharp.Memory |
|
|
[MethodImpl(InliningOptions.ColdPath)] |
|
|
[MethodImpl(InliningOptions.ColdPath)] |
|
|
private Memory<T> GetSingleMemorySlow() => this.FastMemoryGroup.Single(); |
|
|
private Memory<T> GetSingleMemorySlow() => this.FastMemoryGroup.Single(); |
|
|
|
|
|
|
|
|
|
|
|
[MethodImpl(InliningOptions.ColdPath)] |
|
|
|
|
|
private Span<T> GetSingleSpanSlow() => this.FastMemoryGroup.Single().Span; |
|
|
|
|
|
|
|
|
[MethodImpl(InliningOptions.ColdPath)] |
|
|
[MethodImpl(InliningOptions.ColdPath)] |
|
|
private ref T GetElementSlow(int x, int y) |
|
|
private ref T GetElementSlow(int x, int y) |
|
|
{ |
|
|
{ |
|
|
@ -230,17 +233,5 @@ namespace SixLabors.ImageSharp.Memory |
|
|
b.cachedMemory = aCached; |
|
|
b.cachedMemory = aCached; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[MethodImpl(InliningOptions.ColdPath)] |
|
|
|
|
|
private static Memory<T> ThrowInvalidOperationSingleMemory() |
|
|
|
|
|
{ |
|
|
|
|
|
throw new InvalidOperationException("GetSingleMemory is only valid for a single-buffer group!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[MethodImpl(InliningOptions.ColdPath)] |
|
|
|
|
|
private static Span<T> ThrowInvalidOperationSingleSpan() |
|
|
|
|
|
{ |
|
|
|
|
|
throw new InvalidOperationException("GetSingleSpan is only valid for a single-buffer group!"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|