Browse Source

inlining

af/merge-core
Anton Firszov 9 years ago
parent
commit
81ce9f5977
  1. 2
      src/ImageSharp/Colors/Color.BulkOperations.cs
  2. 2
      src/ImageSharp/Common/Memory/BufferPointer.cs
  3. 4
      src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs

2
src/ImageSharp/Colors/Color.BulkOperations.cs

@ -66,7 +66,7 @@ namespace ImageSharp
for (; src < srcEnd; src++, dst++) for (; src < srcEnd; src++, dst++)
{ {
// TODO: We can benefit a lot of future Vector<T> API-s here (https://github.com/dotnet/corefx/issues/15957) // TODO: This is the bottleneck now. We can improve it with future Vector<T> API-s (https://github.com/dotnet/corefx/issues/15957)
dst->Load(*src); dst->Load(*src);
} }

2
src/ImageSharp/Common/Memory/BufferPointer.cs

@ -16,7 +16,7 @@ namespace ImageSharp
internal static class BufferPointer internal static class BufferPointer
{ {
/// <summary> /// <summary>
/// It's worth to use Marshal.Copy() over this size. /// It's worth to use Marshal.Copy() or Buffer.BlockCopy() over this size.
/// </summary> /// </summary>
private const int ByteCountThreshold = 1024; private const int ByteCountThreshold = 1024;

4
src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs

@ -142,6 +142,7 @@ namespace ImageSharp
/// <summary> /// <summary>
/// Disposes the <see cref="PinnedBuffer{T}"/> instance by unpinning the array, and returning the pooled buffer when necessary. /// Disposes the <see cref="PinnedBuffer{T}"/> instance by unpinning the array, and returning the pooled buffer when necessary.
/// </summary> /// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Dispose() public void Dispose()
{ {
if (this.IsDisposedOrLostArrayOwnership) if (this.IsDisposedOrLostArrayOwnership)
@ -165,6 +166,7 @@ namespace ImageSharp
/// If <see cref="Array"/> is rented, it's the callers responsibility to return it to it's pool. (Most likely <see cref="PixelDataPool{T}"/>) /// If <see cref="Array"/> is rented, it's the callers responsibility to return it to it's pool. (Most likely <see cref="PixelDataPool{T}"/>)
/// </summary> /// </summary>
/// <returns>The unpinned <see cref="Array"/></returns> /// <returns>The unpinned <see cref="Array"/></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T[] UnPinAndTakeArrayOwnership() public T[] UnPinAndTakeArrayOwnership()
{ {
if (this.IsDisposedOrLostArrayOwnership) if (this.IsDisposedOrLostArrayOwnership)
@ -182,6 +184,7 @@ namespace ImageSharp
/// <summary> /// <summary>
/// Pins <see cref="Array"/>. /// Pins <see cref="Array"/>.
/// </summary> /// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void Pin() private void Pin()
{ {
this.handle = GCHandle.Alloc(this.Array, GCHandleType.Pinned); this.handle = GCHandle.Alloc(this.Array, GCHandleType.Pinned);
@ -191,6 +194,7 @@ namespace ImageSharp
/// <summary> /// <summary>
/// Unpins <see cref="Array"/>. /// Unpins <see cref="Array"/>.
/// </summary> /// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void UnPin() private void UnPin()
{ {
if (this.Pointer == IntPtr.Zero || !this.handle.IsAllocated) if (this.Pointer == IntPtr.Zero || !this.handle.IsAllocated)

Loading…
Cancel
Save