+Sun Aug 19 21:32:39 2001 Owen Taylor <otaylor@redhat.com>
+
+ * glib/ghash.c: Eliminate use of floating point when
+ determining if the hash table needs to be resized,
+ and also factor out the test from g_hash_table_resize()
+ to save function calls for the common case.
+ (#59124)
+
+ * glib/gmain.c (g_main_context_query): Document the
+ return value.
+
2001-08-19 Darin Adler <darin@bentspoon.com>
* glib/gshell.c: (g_shell_quote): Added missing \ character.
+Sun Aug 19 21:32:39 2001 Owen Taylor <otaylor@redhat.com>
+
+ * glib/ghash.c: Eliminate use of floating point when
+ determining if the hash table needs to be resized,
+ and also factor out the test from g_hash_table_resize()
+ to save function calls for the common case.
+ (#59124)
+
+ * glib/gmain.c (g_main_context_query): Document the
+ return value.
+
2001-08-19 Darin Adler <darin@bentspoon.com>
* glib/gshell.c: (g_shell_quote): Added missing \ character.
+Sun Aug 19 21:32:39 2001 Owen Taylor <otaylor@redhat.com>
+
+ * glib/ghash.c: Eliminate use of floating point when
+ determining if the hash table needs to be resized,
+ and also factor out the test from g_hash_table_resize()
+ to save function calls for the common case.
+ (#59124)
+
+ * glib/gmain.c (g_main_context_query): Document the
+ return value.
+
2001-08-19 Darin Adler <darin@bentspoon.com>
* glib/gshell.c: (g_shell_quote): Added missing \ character.
+Sun Aug 19 21:32:39 2001 Owen Taylor <otaylor@redhat.com>
+
+ * glib/ghash.c: Eliminate use of floating point when
+ determining if the hash table needs to be resized,
+ and also factor out the test from g_hash_table_resize()
+ to save function calls for the common case.
+ (#59124)
+
+ * glib/gmain.c (g_main_context_query): Document the
+ return value.
+
2001-08-19 Darin Adler <darin@bentspoon.com>
* glib/gshell.c: (g_shell_quote): Added missing \ character.
+Sun Aug 19 21:32:39 2001 Owen Taylor <otaylor@redhat.com>
+
+ * glib/ghash.c: Eliminate use of floating point when
+ determining if the hash table needs to be resized,
+ and also factor out the test from g_hash_table_resize()
+ to save function calls for the common case.
+ (#59124)
+
+ * glib/gmain.c (g_main_context_query): Document the
+ return value.
+
2001-08-19 Darin Adler <darin@bentspoon.com>
* glib/gshell.c: (g_shell_quote): Added missing \ character.
+Sun Aug 19 21:32:39 2001 Owen Taylor <otaylor@redhat.com>
+
+ * glib/ghash.c: Eliminate use of floating point when
+ determining if the hash table needs to be resized,
+ and also factor out the test from g_hash_table_resize()
+ to save function calls for the common case.
+ (#59124)
+
+ * glib/gmain.c (g_main_context_query): Document the
+ return value.
+
2001-08-19 Darin Adler <darin@bentspoon.com>
* glib/gshell.c: (g_shell_quote): Added missing \ character.
+Sun Aug 19 21:32:39 2001 Owen Taylor <otaylor@redhat.com>
+
+ * glib/ghash.c: Eliminate use of floating point when
+ determining if the hash table needs to be resized,
+ and also factor out the test from g_hash_table_resize()
+ to save function calls for the common case.
+ (#59124)
+
+ * glib/gmain.c (g_main_context_query): Document the
+ return value.
+
2001-08-19 Darin Adler <darin@bentspoon.com>
* glib/gshell.c: (g_shell_quote): Added missing \ character.
+Sun Aug 19 21:32:39 2001 Owen Taylor <otaylor@redhat.com>
+
+ * glib/ghash.c: Eliminate use of floating point when
+ determining if the hash table needs to be resized,
+ and also factor out the test from g_hash_table_resize()
+ to save function calls for the common case.
+ (#59124)
+
+ * glib/gmain.c (g_main_context_query): Document the
+ return value.
+
2001-08-19 Darin Adler <darin@bentspoon.com>
* glib/gshell.c: (g_shell_quote): Added missing \ character.
GDestroyNotify value_destroy_func;
};
+#define G_HASH_TABLE_RESIZE(hash_table) \
+ G_STMT_START { \
+ if ((hash_table->size >= 3 * hash_table->nnodes && \
+ hash_table->size > HASH_TABLE_MIN_SIZE) || \
+ (3 * hash_table->size <= hash_table->nnodes && \
+ hash_table->size < HASH_TABLE_MAX_SIZE)) \
+ g_hash_table_resize (hash_table); \
+ } G_STMT_END
static void g_hash_table_resize (GHashTable *hash_table);
static GHashNode** g_hash_table_lookup_node (GHashTable *hash_table,
{
*node = g_hash_node_new (key, value);
hash_table->nnodes++;
- g_hash_table_resize (hash_table);
+ G_HASH_TABLE_RESIZE (hash_table);
}
}
{
*node = g_hash_node_new (key, value);
hash_table->nnodes++;
- g_hash_table_resize (hash_table);
+ G_HASH_TABLE_RESIZE (hash_table);
}
}
hash_table->value_destroy_func);
hash_table->nnodes--;
- g_hash_table_resize (hash_table);
+ G_HASH_TABLE_RESIZE (hash_table);
return TRUE;
}
g_hash_node_destroy (dest, NULL, NULL);
hash_table->nnodes--;
- g_hash_table_resize (hash_table);
+ G_HASH_TABLE_RESIZE (hash_table);
return TRUE;
}
}
}
- g_hash_table_resize (hash_table);
+ G_HASH_TABLE_RESIZE (hash_table);
return deleted;
}
GHashNode **new_nodes;
GHashNode *node;
GHashNode *next;
- gfloat nodes_per_list;
guint hash_val;
gint new_size;
gint i;
-
- nodes_per_list = (gfloat) hash_table->nnodes / (gfloat) hash_table->size;
-
- if ((nodes_per_list > 0.3 || hash_table->size <= HASH_TABLE_MIN_SIZE) &&
- (nodes_per_list < 3.0 || hash_table->size >= HASH_TABLE_MAX_SIZE))
- return;
-
+
new_size = CLAMP(g_spaced_primes_closest (hash_table->nnodes),
HASH_TABLE_MIN_SIZE,
HASH_TABLE_MAX_SIZE);
*
* Determines information necessary to poll this main loop.
*
- * Return value:
+ * Return value: the number of records actually stored in @fds,
+ * or, if more than @n_fds records need to be stored, the number
+ * of records that need to be stored.
**/
gint
g_main_context_query (GMainContext *context,