changeset 4777:c69aeb86b2a3

Serialise non-default hash table rehash thresholds correctly; use this. src/ChangeLog addition: 2009-12-17 Aidan Kehoe <kehoea@parhasard.net> * elhash.c (HASH_TABLE_DEFAULT_REHASH_THRESHOLD): New macro, giving a default value for a hash table's rehash threshold given its size and test function. (print_hash_table): Print the hash table's rehash threshold if it has a non-default value. Ditto for its rehash size. (Fmake_hash_table): Supply the keyword arguments in a format understood by #'function-arglist. lisp/ChangeLog addition: 2009-12-17 Aidan Kehoe <kehoea@parhasard.net> * mule/make-coding-system.el (fixed-width-create-decode-encode-tables): Use a rehash threshold of 0.999 for this hash table, now that hash table rehash thresholds are serialised correctly; these hash tables will never be resized, and it's not even that important that they are *that* fast, for most of the coding systems they're used a minority of the time.
author Aidan Kehoe <kehoea@parhasard.net>
date Thu, 17 Dec 2009 13:50:45 +0000
parents 73e8632018ad
children 0081fd36b783
files lisp/ChangeLog lisp/mule/make-coding-system.el src/ChangeLog src/elhash.c
diffstat 4 files changed, 40 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Thu Dec 17 13:15:04 2009 +0000
+++ b/lisp/ChangeLog	Thu Dec 17 13:50:45 2009 +0000
@@ -1,3 +1,13 @@
+2009-12-17  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* mule/make-coding-system.el
+	(fixed-width-create-decode-encode-tables):
+	Use a rehash threshold of 0.999 for this hash table, now that hash
+	table rehash thresholds are serialised correctly; these hash
+	tables will never be resized, and it's not even that important
+	that they are *that* fast, for most of the coding systems they're
+	used a minority of the time.
+
 2009-12-05  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	* font.el (x-font-create-object): Check for Xft before using it.
--- a/lisp/mule/make-coding-system.el	Thu Dec 17 13:15:04 2009 +0000
+++ b/lisp/mule/make-coding-system.el	Thu Dec 17 13:50:45 2009 +0000
@@ -322,7 +322,7 @@
 to 256 distinct characters."
   (check-argument-type #'listp unicode-map)
   (let ((decode-table (make-vector 256 nil))
-        (encode-table (make-hash-table :size 256))
+        (encode-table (make-hash-table :size 256 :rehash-threshold 0.999))
 	(private-use-start (encode-char fixed-width-private-use-start 'ucs))
         (invalid-sequence-code-point-start
          (eval-when-compile
--- a/src/ChangeLog	Thu Dec 17 13:15:04 2009 +0000
+++ b/src/ChangeLog	Thu Dec 17 13:50:45 2009 +0000
@@ -1,3 +1,13 @@
+2009-12-17  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* elhash.c (HASH_TABLE_DEFAULT_REHASH_THRESHOLD):
+	New macro, giving a default value for a hash table's rehash
+	threshold given its size and test function. 
+	(print_hash_table): Print the hash table's rehash threshold if it
+	has a non-default value. Ditto for its rehash size. 
+	(Fmake_hash_table): Supply the keyword arguments in a format
+	understood by #'function-arglist. 
+
 2009-12-17  Aidan Kehoe  <kehoea@parhasard.net>
 
 	* alloc.c (resize_string): 
--- a/src/elhash.c	Thu Dec 17 13:15:04 2009 +0000
+++ b/src/elhash.c	Thu Dec 17 13:50:45 2009 +0000
@@ -118,6 +118,8 @@
 #define HASH_TABLE_DEFAULT_SIZE 16
 #define HASH_TABLE_DEFAULT_REHASH_SIZE 1.3
 #define HASH_TABLE_MIN_SIZE 10
+#define HASH_TABLE_DEFAULT_REHASH_THRESHOLD(size, test_function) \
+  ((size) > 4096 && (test_function) == HASH_TABLE_EQ ? 0.7 : 0.6)
 
 #define HASHCODE(key, ht)						\
   ((((ht)->hash_function ? (ht)->hash_function (key) : LISP_HASH (key))	\
@@ -353,6 +355,7 @@
 		  int UNUSED (escapeflag))
 {
   Lisp_Hash_Table *ht = XHASH_TABLE (obj);
+  Ascbyte pigbuf[350];
 
   write_c_string (printcharfun,
 		  print_readably ? "#s(hash-table" : "#<hash-table");
@@ -389,6 +392,20 @@
 	  "you-d-better-not-see-this"));
     }
 
+  if (ht->rehash_size != HASH_TABLE_DEFAULT_REHASH_SIZE)
+    {
+      float_to_string (pigbuf, ht->rehash_size);
+      write_fmt_string (printcharfun, " rehash-size %s", pigbuf);
+    }
+
+  if (ht->rehash_threshold
+      != HASH_TABLE_DEFAULT_REHASH_THRESHOLD (ht->size,
+					      ht->test_function))
+    {
+      float_to_string (pigbuf, ht->rehash_threshold);
+      write_fmt_string (printcharfun, " rehash-threshold %s", pigbuf);
+    }
+
   if (ht->count)
     print_hash_table_data (ht, printcharfun);
 
@@ -591,7 +608,7 @@
 
   ht->rehash_threshold =
     rehash_threshold > 0.0 ? rehash_threshold :
-    size > 4096 && !ht->test_function ? 0.7 : 0.6;
+    HASH_TABLE_DEFAULT_REHASH_THRESHOLD (size, ht->test_function);
 
   if (size < HASH_TABLE_MIN_SIZE)
     size = HASH_TABLE_MIN_SIZE;
@@ -912,7 +929,6 @@
 DEFUN ("make-hash-table", Fmake_hash_table, 0, MANY, 0, /*
 Return a new empty hash table object.
 Use Common Lisp style keywords to specify hash table properties.
- (make-hash-table &key test size rehash-size rehash-threshold weakness)
 
 Keyword :test can be `eq', `eql' (default) or `equal'.
 Comparison between keys is done using this function.
@@ -957,7 +973,7 @@
 hash table if the value or key are pointed to by something other than a weak
 hash table, even if the other is not.
 
-arguments: (&rest ARGS)
+arguments: (&key TEST SIZE REHASH-SIZE REHASH-THRESHOLD WEAKNESS)
 */
        (int nargs, Lisp_Object *args))
 {