emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r110847: * src/lisp.h (XHASH): Redefi


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r110847: * src/lisp.h (XHASH): Redefine to be imperfect and fit in a Lisp int.
Date: Thu, 08 Nov 2012 16:58:55 -0500
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 110847
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Thu 2012-11-08 16:58:55 -0500
message:
  * src/lisp.h (XHASH): Redefine to be imperfect and fit in a Lisp int.
  * src/fns.c (hashfn_eq, hashfn_eql, sxhash):
  * src/profiler.c (hashfn_profiler): Don't use XUINT on non-integers.
  * src/buffer.c (compare_overlays): Use XLI rather than XHASH.
modified:
  src/ChangeLog
  src/buffer.c
  src/fns.c
  src/lisp.h
  src/print.c
  src/profiler.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-11-08 21:43:34 +0000
+++ b/src/ChangeLog     2012-11-08 21:58:55 +0000
@@ -1,3 +1,10 @@
+2012-11-08  Stefan Monnier  <address@hidden>
+
+       * lisp.h (XHASH): Redefine to be imperfect and fit in a Lisp int.
+       * fns.c (hashfn_eq, hashfn_eql, sxhash):
+       * profiler.c (hashfn_profiler): Don't use XUINT on non-integers.
+       * buffer.c (compare_overlays): Use XLI rather than XHASH.
+
 2012-11-08  Paul Eggert  <address@hidden>
 
        Use same hash function for hashfn_profiler as for hash_string etc.

=== modified file 'src/buffer.c'
--- a/src/buffer.c      2012-11-08 14:10:28 +0000
+++ b/src/buffer.c      2012-11-08 21:58:55 +0000
@@ -3132,8 +3132,8 @@
      between "equal" overlays.  The result can still change between
      invocations of Emacs, but it won't change in the middle of
      `find_field' (bug#6830).  */
-  if (XHASH (s1->overlay) != XHASH (s2->overlay))
-    return XHASH (s1->overlay) < XHASH (s2->overlay) ? -1 : 1;
+  if (!EQ (s1->overlay, s2->overlay))
+    return XLI (s1->overlay) < XLI (s2->overlay) ? -1 : 1;
   return 0;
 }
 

=== modified file 'src/fns.c'
--- a/src/fns.c 2012-11-08 21:43:34 +0000
+++ b/src/fns.c 2012-11-08 21:58:55 +0000
@@ -3479,7 +3479,7 @@
 static EMACS_UINT
 hashfn_eq (struct hash_table_test *ht, Lisp_Object key)
 {
-  EMACS_UINT hash = XUINT (key) ^ XTYPE (key);
+  EMACS_UINT hash = XHASH (key) ^ XTYPE (key);
   return hash;
 }
 
@@ -3494,7 +3494,7 @@
   if (FLOATP (key))
     hash = sxhash (key, 0);
   else
-    hash = XUINT (key) ^ XTYPE (key);
+    hash = XHASH (key) ^ XTYPE (key);
   return hash;
 }
 
@@ -4173,7 +4173,7 @@
       break;
 
     case Lisp_Misc:
-      hash = XUINT (obj);
+      hash = XHASH (obj);
       break;
 
     case Lisp_Symbol:
@@ -4197,7 +4197,7 @@
       else
        /* Others are `equal' if they are `eq', so let's take their
           address as hash.  */
-       hash = XUINT (obj);
+       hash = XHASH (obj);
       break;
 
     case Lisp_Cons:

=== modified file 'src/lisp.h'
--- a/src/lisp.h        2012-11-08 21:43:34 +0000
+++ b/src/lisp.h        2012-11-08 21:58:55 +0000
@@ -454,9 +454,6 @@
  For example, if tem is a Lisp_Object whose type is Lisp_Cons,
  XCONS (tem) is the struct Lisp_Cons * pointing to the memory for that cons.  
*/
 
-/* Return a perfect hash of the Lisp_Object representation.  */
-#define XHASH(a) XLI (a)
-
 #if USE_LSB_TAG
 
 enum lsb_bits
@@ -509,6 +506,11 @@
 
 #endif /* not USE_LSB_TAG */
 
+/* Return a (Lisp-integer sized) hash of the Lisp_Object value.  Happens to be
+   like XUINT right now, but XUINT should only be applied to objects we know
+   are integers.  */
+#define XHASH(a) XUINT (a)
+
 /* For integers known to be positive, XFASTINT sometimes provides
    faster retrieval and XSETFASTINT provides faster storage.
    If not, fallback on the non-accelerated path.  */
@@ -524,7 +526,7 @@
 # define XUNTAG(a, type) XPNTR (a)
 #endif
 
-#define EQ(x, y) (XHASH (x) == XHASH (y))
+#define EQ(x, y) (XLI (x) == XLI (y))
 
 /* Largest and smallest representable fixnum values.  These are the C
    values.  They are macros for use in static initializers.  */

=== modified file 'src/print.c'
--- a/src/print.c       2012-11-08 19:12:23 +0000
+++ b/src/print.c       2012-11-08 21:58:55 +0000
@@ -798,7 +798,7 @@
   else
     fprintf (stderr, "#<%s_LISP_OBJECT 0x%08"pI"x>\r\n",
             !valid ? "INVALID" : "SOME",
-            XHASH (arg));
+            XLI (arg));
 }
 
 

=== modified file 'src/profiler.c'
--- a/src/profiler.c    2012-11-08 21:43:34 +0000
+++ b/src/profiler.c    2012-11-08 21:58:55 +0000
@@ -555,15 +555,15 @@
        {
          Lisp_Object f = AREF (bt, i);
          EMACS_UINT hash1
-           = (COMPILEDP (f) ? XUINT (AREF (f, COMPILED_BYTECODE))
+           = (COMPILEDP (f) ? XHASH (AREF (f, COMPILED_BYTECODE))
               : (CONSP (f) && CONSP (XCDR (f)) && EQ (Qclosure, XCAR (f)))
-              ? XUINT (XCDR (XCDR (f))) : XUINT (f));
+              ? XHASH (XCDR (XCDR (f))) : XHASH (f));
          hash = sxhash_combine (hash, hash1);
        }
       return (hash & INTMASK);
     }
   else
-    return XUINT (bt);
+    return XHASH (bt);
 }
 
 void


reply via email to

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