From eac4ed4b4678d3d9d8a7bc3ea2382c4cd4bd220a Mon Sep 17 00:00:00 2001 From: Juerg Billeter Date: Sun, 22 Jul 2007 18:13:55 +0000 Subject: [PATCH] use lazy initialization for array_types hash table 2007-07-22 Juerg Billeter * vala/valadatatype.vala: use lazy initialization for array_types hash table svn path=/trunk/; revision=369 --- ChangeLog | 5 +++++ vala/valadatatype.vala | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index e5ba85a..a53e180 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2007-07-22 Jürg Billeter + * vala/valadatatype.vala: use lazy initialization for array_types + hash table + +2007-07-22 Jürg Billeter + * vala/valainterface.vala, vala/valainterfacewriter.vala: support libraries with generic types diff --git a/vala/valadatatype.vala b/vala/valadatatype.vala index 8529966..57249d8 100644 --- a/vala/valadatatype.vala +++ b/vala/valadatatype.vala @@ -41,8 +41,7 @@ public abstract class Vala.DataType : Symbol { private Pointer pointer_type; /* holds the array types of this type; each rank is a separate one */ - /* FIXME: uses string because int does not work as key yet */ - private HashTable array_types = new HashTable.full (str_hash, str_equal, g_free, g_object_unref); + private HashTable array_types; /** * Returns the name of this data type as it is used in C code. @@ -235,9 +234,17 @@ public abstract class Vala.DataType : Symbol { * @return array type for this data type */ public Array! get_array (int rank) { - Array array_type = (Array) array_types.lookup (rank.to_string ()); - + Array array_type = null; + + if (array_types != null) { + array_type = array_types.lookup (rank); + } + if (array_type == null) { + if (array_types == null) { + array_types = new HashTable.full (direct_hash, direct_equal, null, g_object_unref); + } + var new_array_type = new Array (this, rank, source_reference); parent_symbol.scope.add (new_array_type.name, new_array_type); @@ -249,7 +256,7 @@ public abstract class Vala.DataType : Symbol { /* link the array type to the same source as the container type */ new_array_type.source_reference = this.source_reference; - array_types.insert (rank.to_string (), new_array_type); + array_types.insert (rank, new_array_type); array_type = new_array_type; } -- 2.7.4