This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gcc 4.5 patch] Permit smaller hash tables for hash_map and hash_set


Do we have a general policy for patches to hash_map and hash_set, now
that they have moved to include/backward?

I have a few patches to make them better in some circumstances.  These
ideas are incorporated in different from in the newer unordered_set and
unordered_map.  However, existing code still uses hash_map and hash_set,
so it may be useful to update them if we think that is OK.

Anyhow, this patch permits hash_{map,set} to be smaller.  This is useful
because not every hash table is large.  In unordered_{map,set} we permit
the number of buckets to start at 2.  This patch simply adds the number
5 at the start of the list of bucket counts for hash_{map,set}, so that
at least they don't have to start with 53 buckets.

Is this patch OK for gcc 4.5?

Ian


2009-02-06  Ian Lance Taylor  <iant@google.com>

	* include/backward/hashtable.h (_S_num_primes): Change to 29.
	(__stl_prime_list): Add 5 at the start of the list.


Index: libstdc++-v3/include/backward/hashtable.h
===================================================================
--- libstdc++-v3/include/backward/hashtable.h	(revision 143986)
+++ libstdc++-v3/include/backward/hashtable.h	(working copy)
@@ -210,16 +210,16 @@
     };
 
   // Note: assumes long is at least 32 bits.
-  enum { _S_num_primes = 28 };
+  enum { _S_num_primes = 29 };
 
   static const unsigned long __stl_prime_list[_S_num_primes] =
     {
-      53ul,         97ul,         193ul,       389ul,       769ul,
-      1543ul,       3079ul,       6151ul,      12289ul,     24593ul,
-      49157ul,      98317ul,      196613ul,    393241ul,    786433ul,
-      1572869ul,    3145739ul,    6291469ul,   12582917ul,  25165843ul,
-      50331653ul,   100663319ul,  201326611ul, 402653189ul, 805306457ul,
-      1610612741ul, 3221225473ul, 4294967291ul
+      5ul,          53ul,         97ul,         193ul,       389ul,
+      769ul,        1543ul,       3079ul,       6151ul,      12289ul,
+      24593ul,      49157ul,      98317ul,      196613ul,    393241ul,
+      786433ul,     1572869ul,    3145739ul,    6291469ul,   12582917ul,
+      25165843ul,   50331653ul,   100663319ul,  201326611ul, 402653189ul,
+      805306457ul,  1610612741ul, 3221225473ul, 4294967291ul
     };
 
   inline unsigned long

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]