From eddc5fa796eb17d07ec0ed7f67a4122316f18c47 Mon Sep 17 00:00:00 2001 From: Bertrand Lorentz Date: Sun, 4 Nov 2012 16:34:54 +0100 Subject: [PATCH] generator: Use a Dictionary to hold the class structs cache Again, nicer generated code, and no impact outside of it. --- generator/ObjectGen.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/generator/ObjectGen.cs b/generator/ObjectGen.cs index b316325ca..774a797da 100644 --- a/generator/ObjectGen.cs +++ b/generator/ObjectGen.cs @@ -316,15 +316,15 @@ namespace GtkSharp.Generation { sw.WriteLine ("\t\tstatic uint class_offset = 0;"); else sw.WriteLine ("\t\tstatic uint class_offset = ((GLib.GType) typeof ({0})).GetClassSize ();", cs_parent); - sw.WriteLine ("\t\tstatic Hashtable class_structs;"); + sw.WriteLine ("\t\tstatic Dictionary class_structs;", class_struct_name); sw.WriteLine (); sw.WriteLine ("\t\tstatic {0} GetClassStruct (GLib.GType gtype, bool use_cache)", class_struct_name); sw.WriteLine ("\t\t{"); sw.WriteLine ("\t\t\tif (class_structs == null)"); - sw.WriteLine ("\t\t\t\tclass_structs = new Hashtable ();"); + sw.WriteLine ("\t\t\t\tclass_structs = new Dictionary ();", class_struct_name); sw.WriteLine (); - sw.WriteLine ("\t\t\tif (use_cache && class_structs.Contains (gtype))"); - sw.WriteLine ("\t\t\t\treturn ({0}) class_structs [gtype];", class_struct_name); + sw.WriteLine ("\t\t\tif (use_cache && class_structs.ContainsKey (gtype))"); + sw.WriteLine ("\t\t\t\treturn class_structs [gtype];"); sw.WriteLine ("\t\t\telse {"); sw.WriteLine ("\t\t\t\tIntPtr class_ptr = new IntPtr (gtype.GetClassPtr ().ToInt64 () + class_offset);"); sw.WriteLine ("\t\t\t\t{0} class_struct = ({0}) Marshal.PtrToStructure (class_ptr, typeof ({0}));", class_struct_name);