emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r110846: Use same hash function for h


From: Paul Eggert
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r110846: Use same hash function for hashfn_profiler as for hash_string etc.
Date: Thu, 08 Nov 2012 13:43:34 -0800
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 110846
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Thu 2012-11-08 13:43:34 -0800
message:
  Use same hash function for hashfn_profiler as for hash_string etc.
  
  * fns.c (SXHASH_COMBINE): Remove.  All uses replaced by sxhash_combine.
  * lisp.h (sxhash_combine): New inline function, with the contents
  of the old SXHASH_COMBINE.
  * profiler.c (hashfn_profiler): Use it, instead of having a
  special hash function containing a comparison that always yields 1.
modified:
  src/ChangeLog
  src/fns.c
  src/lisp.h
  src/profiler.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-11-08 21:02:10 +0000
+++ b/src/ChangeLog     2012-11-08 21:43:34 +0000
@@ -1,3 +1,12 @@
+2012-11-08  Paul Eggert  <address@hidden>
+
+       Use same hash function for hashfn_profiler as for hash_string etc.
+       * fns.c (SXHASH_COMBINE): Remove.  All uses replaced by sxhash_combine.
+       * lisp.h (sxhash_combine): New inline function, with the contents
+       of the old SXHASH_COMBINE.
+       * profiler.c (hashfn_profiler): Use it, instead of having a
+       special hash function containing a comparison that always yields 1.
+
 2012-11-08  Stefan Monnier  <address@hidden>
 
        * xfaces.c (Qultra_light, Qreverse_oblique, Qreverse_italic)

=== modified file 'src/fns.c'
--- a/src/fns.c 2012-11-08 19:12:23 +0000
+++ b/src/fns.c 2012-11-08 21:43:34 +0000
@@ -4036,13 +4036,6 @@
 
 #define SXHASH_MAX_LEN   7
 
-/* Combine two integers X and Y for hashing.  The result might not fit
-   into a Lisp integer.  */
-
-#define SXHASH_COMBINE(X, Y)                                           \
-  ((((EMACS_UINT) (X) << 4) + ((EMACS_UINT) (X) >> (BITS_PER_EMACS_INT - 4))) \
-   + (EMACS_UINT) (Y))
-
 /* Hash X, returning a value that fits into a Lisp integer.  */
 #define SXHASH_REDUCE(X) \
   ((((X) ^ (X) >> (BITS_PER_EMACS_INT - FIXNUM_BITS))) & INTMASK)
@@ -4061,7 +4054,7 @@
   while (p != end)
     {
       c = *p++;
-      hash = SXHASH_COMBINE (hash, c);
+      hash = sxhash_combine (hash, c);
     }
 
   return hash;
@@ -4095,7 +4088,7 @@
   u.val = val;
   memset (&u.val + 1, 0, sizeof u - sizeof u.val);
   for (i = 0; i < WORDS_PER_DOUBLE; i++)
-    hash = SXHASH_COMBINE (hash, u.word[i]);
+    hash = sxhash_combine (hash, u.word[i]);
   return SXHASH_REDUCE (hash);
 }
 
@@ -4114,13 +4107,13 @@
         list = XCDR (list), ++i)
       {
        EMACS_UINT hash2 = sxhash (XCAR (list), depth + 1);
-       hash = SXHASH_COMBINE (hash, hash2);
+       hash = sxhash_combine (hash, hash2);
       }
 
   if (!NILP (list))
     {
       EMACS_UINT hash2 = sxhash (list, depth + 1);
-      hash = SXHASH_COMBINE (hash, hash2);
+      hash = sxhash_combine (hash, hash2);
     }
 
   return SXHASH_REDUCE (hash);
@@ -4140,7 +4133,7 @@
   for (i = 0; i < n; ++i)
     {
       EMACS_UINT hash2 = sxhash (AREF (vec, i), depth + 1);
-      hash = SXHASH_COMBINE (hash, hash2);
+      hash = sxhash_combine (hash, hash2);
     }
 
   return SXHASH_REDUCE (hash);
@@ -4156,7 +4149,7 @@
 
   n = min (SXHASH_MAX_LEN, XBOOL_VECTOR (vec)->header.size);
   for (i = 0; i < n; ++i)
-    hash = SXHASH_COMBINE (hash, XBOOL_VECTOR (vec)->data[i]);
+    hash = sxhash_combine (hash, XBOOL_VECTOR (vec)->data[i]);
 
   return SXHASH_REDUCE (hash);
 }

=== modified file 'src/lisp.h'
--- a/src/lisp.h        2012-11-08 19:12:23 +0000
+++ b/src/lisp.h        2012-11-08 21:43:34 +0000
@@ -438,7 +438,7 @@
     /* To calculate the memory footprint of the pseudovector, it's useful
        to store the size of non-Lisp area in word_size units here.  */
     PSEUDOVECTOR_REST_BITS = 12,
-    PSEUDOVECTOR_REST_MASK = (((1 << PSEUDOVECTOR_REST_BITS) - 1) 
+    PSEUDOVECTOR_REST_MASK = (((1 << PSEUDOVECTOR_REST_BITS) - 1)
                              << PSEUDOVECTOR_SIZE_BITS),
 
     /* Used to extract pseudovector subtype information.  */
@@ -1284,6 +1284,15 @@
 
 static double const DEFAULT_REHASH_SIZE = 1.5;
 
+/* Combine two integers X and Y for hashing.  The result might not fit
+   into a Lisp integer.  */
+
+LISP_INLINE EMACS_UINT
+sxhash_combine (EMACS_UINT x, EMACS_UINT y)
+{
+  return (x << 4) + (x >> (BITS_PER_EMACS_INT - 4)) + y;
+}
+
 /* These structures are used for various misc types.  */
 
 struct Lisp_Misc_Any           /* Supertype of all Misc types.  */

=== modified file 'src/profiler.c'
--- a/src/profiler.c    2012-11-08 19:12:23 +0000
+++ b/src/profiler.c    2012-11-08 21:43:34 +0000
@@ -558,7 +558,7 @@
            = (COMPILEDP (f) ? XUINT (AREF (f, COMPILED_BYTECODE))
               : (CONSP (f) && CONSP (XCDR (f)) && EQ (Qclosure, XCAR (f)))
               ? XUINT (XCDR (XCDR (f))) : XUINT (f));
-         hash = hash1 + (hash << 1) + (hash == (EMACS_INT) hash);
+         hash = sxhash_combine (hash, hash1);
        }
       return (hash & INTMASK);
     }


reply via email to

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