[glib/halfline/debug-metrics: 10/19] ghash: Allow tweaking hash table shift by environment variable




commit 8d99a5649c5b93ed368d0e8b60b7b9839d1f22a1
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 608d136f4..869ef42e6 100644
--- a/glib/ghash.c
+++ b/glib/ghash.c
@@ -206,7 +206,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
@@ -714,7 +714,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]