[corlib] change Mono.SafeGPtrArrayHandle to a struct
authorAleksey Kliger <aleksey@xamarin.com>
Thu, 28 Jul 2016 14:59:14 +0000 (10:59 -0400)
committerAleksey Kliger <aleksey@xamarin.com>
Thu, 28 Jul 2016 14:59:14 +0000 (10:59 -0400)
Don't GC allocate short-lived internal garbage.

mcs/class/corlib/Mono/SafeGPtrArrayHandle.cs

index 133af690678aa0653db6ba86be4cd8f6c802d606..0441c9b8bd8b9dcbafdf7cd95c222c97558d32b3 100644 (file)
@@ -13,7 +13,7 @@ using System;
 using System.Runtime.CompilerServices;
 
 namespace Mono {
-       internal sealed class SafeGPtrArrayHandle : IDisposable {
+       internal struct SafeGPtrArrayHandle : IDisposable {
                RuntimeGPtrArrayHandle handle;
 
                internal SafeGPtrArrayHandle (IntPtr ptr)
@@ -21,19 +21,8 @@ namespace Mono {
                        handle = new RuntimeGPtrArrayHandle (ptr);
                }
 
-               ~SafeGPtrArrayHandle ()
-               {
-                       Dispose (false);
-               }
-
-               void Dispose (bool disposing)
-               {
-                       RuntimeGPtrArrayHandle.DestroyAndFree (ref handle);
-               }
-
                public void Dispose () {
-                       Dispose (true);
-                       GC.SuppressFinalize (this);
+                       RuntimeGPtrArrayHandle.DestroyAndFree (ref handle);
                }
 
                internal int Length {