emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master c8d14cf: Fix glitches in recent hash table changes


From: Paul Eggert
Subject: [Emacs-diffs] master c8d14cf: Fix glitches in recent hash table changes
Date: Sun, 19 Feb 2017 15:25:57 -0500 (EST)

branch: master
commit c8d14cfc6c2d19077d137c7e917fbb4f104de222
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Fix glitches in recent hash table changes
    
    * src/fns.c (Fmake_hash_table): Simplify the machine code slightly
    by using 0 rather than -1.
    * src/lisp.h (struct Lisp_Hash_Table.pure): Now bool rather
    than a bitfield, for speed (the bitfield did not save space).
    (struct Lisp_Hash_Table.rehash_threshold): Now double rather than
    float, since the float caused unwanted rounding errors, e.g.,
    (hash-table-rehash-threshold (make-hash-table)) yielded
    0.800000011920929 instead of the correct 0.8.
---
 src/fns.c  |  5 ++---
 src/lisp.h | 10 +++++-----
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/fns.c b/src/fns.c
index be00bfd..3fed92d 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -4445,9 +4445,8 @@ usage: (make-hash-table &rest KEYWORD-ARGS)  */)
 
   /* Look for `:rehash-threshold THRESHOLD'.  */
   i = get_key_arg (QCrehash_threshold, nargs, args, used);
-  rehash_threshold =
-    i ? (FLOATP (args[i]) ? XFLOAT_DATA (args[i]) : -1.0)
-    : DEFAULT_REHASH_THRESHOLD;
+  rehash_threshold = (!i ? DEFAULT_REHASH_THRESHOLD
+                     : FLOATP (args[i]) ? XFLOAT_DATA (args[i]) : 0);
   if (! (0 < rehash_threshold && rehash_threshold <= 1))
     signal_error ("Invalid hash table rehash threshold", args[i]);
 
diff --git a/src/lisp.h b/src/lisp.h
index d803072..be42b33 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -1998,13 +1998,13 @@ struct Lisp_Hash_Table
   /* Number of key/value entries in the table.  */
   ptrdiff_t count;
 
-  /* Non-nil if the table can be purecopied.  The table cannot be
+  /* True if the table can be purecopied.  The table cannot be
      changed afterwards.  */
-  bool_bf pure : 1;
+  bool pure;
 
-  /* Resize hash table when number of entries/ table size is >= this
-     ratio, a float.  */
-  float rehash_threshold;
+  /* Resize hash table when number of entries / table size is >= this
+     ratio.  */
+  double rehash_threshold;
 
   /* Vector of keys and values.  The key of item I is found at index
      2 * I, the value is found at index 2 * I + 1.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]