From ce3db510d7985a87715288ab7b8547ab5c8b50a7 Mon Sep 17 00:00:00 2001 From: Mike Kestner Date: Thu, 12 Jul 2007 21:23:47 +0000 Subject: [PATCH] 2007-07-12 Mike Kestner * generator/StructBase.cs : use typeof to pass type to PtrToStruct to avoid an instantiation and method call. Duh. svn path=/trunk/gtk-sharp/; revision=81907 --- ChangeLog | 7 ++++++- generator/StructBase.cs | 7 ++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1315cb27a..3440369fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,9 @@ -2007-07-03 Mike Kestner +2007-07-12 Mike Kestner + + * generator/StructBase.cs : use typeof to pass type to PtrToStruct + to avoid an instantiation and method call. Duh. + +2007-07-10 Mike Kestner * generator/ImportSignature.cs : use Parameter.NativeSignature prop and refactor out some GError handling. diff --git a/generator/StructBase.cs b/generator/StructBase.cs index 57fc410a9..56b772d1f 100644 --- a/generator/StructBase.cs +++ b/generator/StructBase.cs @@ -190,12 +190,9 @@ namespace GtkSharp.Generation { sw.WriteLine(); if (!DisableNew) { sw.WriteLine ("\t\tpublic static " + QualifiedName + " New(IntPtr raw) {"); - sw.WriteLine ("\t\t\tif (raw == IntPtr.Zero) {"); + sw.WriteLine ("\t\t\tif (raw == IntPtr.Zero)"); sw.WriteLine ("\t\t\t\treturn {0}.Zero;", QualifiedName); - sw.WriteLine ("\t\t\t}"); - sw.WriteLine ("\t\t\t{0} self = new {0}();", QualifiedName); - sw.WriteLine ("\t\t\tself = ({0}) Marshal.PtrToStructure (raw, self.GetType ());", QualifiedName); - sw.WriteLine ("\t\t\treturn self;"); + sw.WriteLine ("\t\t\treturn ({0}) Marshal.PtrToStructure (raw, typeof ({0}));", QualifiedName); sw.WriteLine ("\t\t}"); sw.WriteLine (); }