From 81ce9f59778d84f8a7cf91525565bf539b8b8567 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Wed, 8 Mar 2017 18:42:04 +0100 Subject: [PATCH] inlining --- src/ImageSharp/Colors/Color.BulkOperations.cs | 2 +- src/ImageSharp/Common/Memory/BufferPointer.cs | 2 +- src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ImageSharp/Colors/Color.BulkOperations.cs b/src/ImageSharp/Colors/Color.BulkOperations.cs index 617114dff..154cd531d 100644 --- a/src/ImageSharp/Colors/Color.BulkOperations.cs +++ b/src/ImageSharp/Colors/Color.BulkOperations.cs @@ -66,7 +66,7 @@ namespace ImageSharp for (; src < srcEnd; src++, dst++) { - // TODO: We can benefit a lot of future Vector API-s here (https://github.com/dotnet/corefx/issues/15957) + // TODO: This is the bottleneck now. We can improve it with future Vector API-s (https://github.com/dotnet/corefx/issues/15957) dst->Load(*src); } diff --git a/src/ImageSharp/Common/Memory/BufferPointer.cs b/src/ImageSharp/Common/Memory/BufferPointer.cs index b470b4db5..523889611 100644 --- a/src/ImageSharp/Common/Memory/BufferPointer.cs +++ b/src/ImageSharp/Common/Memory/BufferPointer.cs @@ -16,7 +16,7 @@ namespace ImageSharp internal static class BufferPointer { /// - /// It's worth to use Marshal.Copy() over this size. + /// It's worth to use Marshal.Copy() or Buffer.BlockCopy() over this size. /// private const int ByteCountThreshold = 1024; diff --git a/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs b/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs index 8c81a3206..6e0d1fcc6 100644 --- a/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs +++ b/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs @@ -142,6 +142,7 @@ namespace ImageSharp /// /// Disposes the instance by unpinning the array, and returning the pooled buffer when necessary. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Dispose() { if (this.IsDisposedOrLostArrayOwnership) @@ -165,6 +166,7 @@ namespace ImageSharp /// If is rented, it's the callers responsibility to return it to it's pool. (Most likely ) /// /// The unpinned + [MethodImpl(MethodImplOptions.AggressiveInlining)] public T[] UnPinAndTakeArrayOwnership() { if (this.IsDisposedOrLostArrayOwnership) @@ -182,6 +184,7 @@ namespace ImageSharp /// /// Pins . /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] private void Pin() { this.handle = GCHandle.Alloc(this.Array, GCHandleType.Pinned); @@ -191,6 +194,7 @@ namespace ImageSharp /// /// Unpins . /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] private void UnPin() { if (this.Pointer == IntPtr.Zero || !this.handle.IsAllocated)