+2012-11-08 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * 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 <eggert@cs.ucla.edu>
Use same hash function for hashfn_profiler as for hash_string etc.
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;
}
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;
}
if (FLOATP (key))
hash = sxhash (key, 0);
else
- hash = XUINT (key) ^ XTYPE (key);
+ hash = XHASH (key) ^ XTYPE (key);
return hash;
}
break;
case Lisp_Misc:
- hash = XUINT (obj);
+ hash = XHASH (obj);
break;
case Lisp_Symbol:
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:
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
#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. */
# 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. */
else
fprintf (stderr, "#<%s_LISP_OBJECT 0x%08"pI"x>\r\n",
!valid ? "INVALID" : "SOME",
- XHASH (arg));
+ XLI (arg));
}
\f
{
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