[glib/halfline/debug-metrics: 13/22] ghash: Allow tweaking hash table shift by environment variable
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/halfline/debug-metrics: 13/22] ghash: Allow tweaking hash table shift by environment variable
- Date: Wed, 7 Jul 2021 03:19:01 +0000 (UTC)
commit b6aafad50765c5c2e068fef26aff8925f814799d
Author: Ray Strode <rstrode redhat com>
Date: Mon May 10 16:02:31 2021 -0400
ghash: Allow tweaking hash table shift by environment variable
The shift controls the capacity of the hash table before it needs to
be resized.
This commit makes the shift configurable through the
G_HASH_TABLE_MIN_SHIFT
environment variable.
glib/ghash.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/glib/ghash.c b/glib/ghash.c
index 6bb04a50d..131d4ab99 100644
--- a/glib/ghash.c
+++ b/glib/ghash.c
@@ -205,7 +205,7 @@
* release of GLib. It does nothing.
*/
-#define HASH_TABLE_MIN_SHIFT 3 /* 1 << 3 == 8 buckets */
+static int HASH_TABLE_MIN_SHIFT = 3;
#define UNUSED_HASH_VALUE 0
#define TOMBSTONE_HASH_VALUE 1
@@ -713,7 +713,7 @@ g_hash_table_new_full (GHashFunc hash_func,
GDestroyNotify value_destroy_func)
{
GHashTable *hash_table;
-
+ HASH_TABLE_MIN_SHIFT = atoi(getenv ("G_HASH_TABLE_MIN_SHIFT")? : "3");
hash_table = g_slice_new (GHashTable);
g_hash_table_set_shift (hash_table, HASH_TABLE_MIN_SHIFT);
hash_table->nnodes = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]