]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
use lazy initialization for array_types hash table
authorJuerg Billeter <j@bitron.ch>
Sun, 22 Jul 2007 18:13:55 +0000 (18:13 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Sun, 22 Jul 2007 18:13:55 +0000 (18:13 +0000)
2007-07-22  Juerg Billeter  <j@bitron.ch>

* vala/valadatatype.vala: use lazy initialization for array_types
  hash table

svn path=/trunk/; revision=369

ChangeLog
vala/valadatatype.vala

index e5ba85afe356b00e8c5ecd8a03b3691f77be8ba3..a53e180709951ac4aa9da3da88e0db82d107c49a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-07-22  Jürg Billeter  <j@bitron.ch>
+
+       * vala/valadatatype.vala: use lazy initialization for array_types
+         hash table
+
 2007-07-22  Jürg Billeter  <j@bitron.ch>
 
        * vala/valainterface.vala, vala/valainterfacewriter.vala: support
index 85299666a33950e20e7a23aa9171eec13639f2ae..57249d892c1a02334f3ad85f71aeb6621bf09e8c 100644 (file)
@@ -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<string,Array> array_types = new HashTable.full (str_hash, str_equal, g_free, g_object_unref);
+       private HashTable<int,Array> 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;
                }