2009-12-02 Mark Probst <mark.probst@gmail.com>
authorMark Probst <mark.probst@gmail.com>
Wed, 2 Dec 2009 02:09:13 +0000 (02:09 -0000)
committerMark Probst <mark.probst@gmail.com>
Wed, 2 Dec 2009 02:09:13 +0000 (02:09 -0000)
        * mono-hash.c: Don't use MONO_ROOT_SETREF for setting keys and
        values.  It's unnecessary - the hash table has a marking function
        which takes care of all GC-tracked keys and values.

svn path=/trunk/mono/; revision=147282

mono/utils/ChangeLog
mono/utils/mono-hash.c

index 360db65ddc8e02b90152d77dd7c82db2fe72e37c..86b4215754ae45130d42b3ed0db6751c3ce93a7e 100644 (file)
@@ -1,3 +1,9 @@
+2009-12-02  Mark Probst  <mark.probst@gmail.com>
+
+       * mono-hash.c: Don't use MONO_ROOT_SETREF for setting keys and
+       values.  It's unnecessary - the hash table has a marking function
+       which takes care of all GC-tracked keys and values.
+
 2009-11-26  Zoltan Varga  <vargaz@gmail.com>
 
        * mono-ehash.c (mono_g_hash_table_find): Add this for eglib too.
index 352e4123211f0ab8fa2687b5c3d2d5f7f452305d..4b2e67a685c92c4b275557a0ba30e30e6b6e7c6f 100644 (file)
@@ -76,9 +76,7 @@ struct _MonoGHashTable
 static void            g_hash_table_resize       (MonoGHashTable         *hash_table);
 static MonoGHashNode** g_hash_table_lookup_node  (MonoGHashTable     *hash_table,
                                                    gconstpointer   key);
-static MonoGHashNode*  g_hash_node_new           (gpointer        key,
-                                                   gpointer        value,
-                                                  gint            gc_type);
+static MonoGHashNode*  g_hash_node_new           (gint            gc_type);
 static void            g_hash_node_destroy       (MonoGHashNode          *hash_node,
                                                   MonoGHashGCType type,
                                                    GDestroyNotify  key_destroy_func,
@@ -110,25 +108,8 @@ static void *node_gc_descs [4] = {NULL};
 static MonoGHashNode *node_free_lists [4] = {NULL};
 #endif
 
-#ifdef HAVE_SGEN_GC
-#define SET_NODE_KEY(node, gc_type, val) do { \
-       gpointer __val = (val); \
-       if (gc_type == MONO_HASH_KEY_GC || gc_type == MONO_HASH_KEY_VALUE_GC) \
-               MONO_ROOT_SETREF ((node), key, __val); \
-       else \
-         (node)->key = __val; \
-       } while (0)
-#define SET_NODE_VALUE(node, gc_type, val) do { \
-       gpointer __val = (val); \
-       if (gc_type == MONO_HASH_VALUE_GC || gc_type == MONO_HASH_KEY_VALUE_GC) \
-               MONO_ROOT_SETREF ((node), value, __val); \
-       else \
-         (node)->value = __val; \
-       } while (0)
-#else
 #define SET_NODE_KEY(node, gc_type, val) do { (node)->key = (val); } while (0)
 #define SET_NODE_VALUE(node, gc_type, val) do { (node)->value = (val); } while (0)
-#endif
 
 /**
  * g_hash_table_new:
@@ -363,9 +344,7 @@ mono_g_hash_table_lookup_extended (MonoGHashTable    *hash_table,
 }
 
 static inline MonoGHashNode*
-g_hash_node_new (gpointer key,
-                gpointer value,
-                gint gc_type)
+g_hash_node_new (gint gc_type)
 {
   MonoGHashNode *hash_node = NULL;
 
@@ -431,8 +410,8 @@ g_hash_node_new (gpointer key,
   G_UNLOCK (g_hash_global);
 #endif
 
-  SET_NODE_KEY (hash_node, gc_type, key);
-  SET_NODE_VALUE (hash_node, gc_type, value);
+  hash_node->key = NULL;
+  hash_node->value = NULL;
   hash_node->next = NULL;
   
   return hash_node;
@@ -481,9 +460,12 @@ mono_g_hash_table_insert (MonoGHashTable *hash_table,
     }
   else
     {
-      *node = g_hash_node_new (key, value, hash_table->gc_type);
-      hash_table->nnodes++;
-      G_HASH_TABLE_RESIZE (hash_table);
+           gint gc_type = hash_table->gc_type;
+           *node = g_hash_node_new (gc_type);
+           SET_NODE_KEY (*node, gc_type, key);
+           SET_NODE_VALUE (*node, gc_type, value);
+           hash_table->nnodes++;
+           G_HASH_TABLE_RESIZE (hash_table);
     }
 }
 
@@ -524,9 +506,12 @@ mono_g_hash_table_replace (MonoGHashTable *hash_table,
     }
   else
     {
-      *node = g_hash_node_new (key, value, hash_table->gc_type);
-      hash_table->nnodes++;
-      G_HASH_TABLE_RESIZE (hash_table);
+           gint gc_type = hash_table->gc_type;
+           *node = g_hash_node_new (gc_type);
+           SET_NODE_KEY (*node, gc_type, key);
+           SET_NODE_VALUE (*node, gc_type, value);
+           hash_table->nnodes++;
+           G_HASH_TABLE_RESIZE (hash_table);
     }
 }