aboutsummaryrefslogtreecommitdiffstats
path: root/src/lisp.h
diff options
context:
space:
mode:
authorPaul Eggert2013-02-09 14:42:33 -0800
committerPaul Eggert2013-02-09 14:42:33 -0800
commiteff1c1900f47ec5dfb6d435325b366362d09d2db (patch)
tree9db491fe10a82b95f493b8ae6cdfc3d56103b2fa /src/lisp.h
parent4dde2087c47f0ef2a97c3b39d89b94b8a47baf37 (diff)
downloademacs-eff1c1900f47ec5dfb6d435325b366362d09d2db.tar.gz
emacs-eff1c1900f47ec5dfb6d435325b366362d09d2db.zip
Minor hashing refactoring.
* fns.c (SXHASH_REDUCE): Move to lisp.h. (sxhash_float): Return EMACS_UINT, for consistency with the other hash functions. * lisp.h (INTMASK): Now a macro, since SXHASH_REDUCE is now a non-static inline function and therefore can't use static vars. (SXHASH_REDUCE): Move here from fns.c, and make it inline. * profiler.c (hashfn_profiler): Use SXHASH_REDUCE, to be consistent with the other hash functions.
Diffstat (limited to 'src/lisp.h')
-rw-r--r--src/lisp.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/lisp.h b/src/lisp.h
index c15e83bd51c..14db66c6793 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -227,7 +227,7 @@ enum enum_USE_LSB_TAG { USE_LSB_TAG = 0 };
227 227
228/* Lisp integers use 2 tags, to give them one extra bit, thus 228/* Lisp integers use 2 tags, to give them one extra bit, thus
229 extending their range from, e.g., -2^28..2^28-1 to -2^29..2^29-1. */ 229 extending their range from, e.g., -2^28..2^28-1 to -2^29..2^29-1. */
230static EMACS_INT const INTMASK = EMACS_INT_MAX >> (INTTYPEBITS - 1); 230#define INTMASK (EMACS_INT_MAX >> (INTTYPEBITS - 1))
231#define case_Lisp_Int case Lisp_Int0: case Lisp_Int1 231#define case_Lisp_Int case Lisp_Int0: case Lisp_Int1
232#define LISP_INT_TAG_P(x) (((x) & ~Lisp_Int1) == 0) 232#define LISP_INT_TAG_P(x) (((x) & ~Lisp_Int1) == 0)
233 233
@@ -1304,6 +1304,14 @@ sxhash_combine (EMACS_UINT x, EMACS_UINT y)
1304 return (x << 4) + (x >> (BITS_PER_EMACS_INT - 4)) + y; 1304 return (x << 4) + (x >> (BITS_PER_EMACS_INT - 4)) + y;
1305} 1305}
1306 1306
1307/* Hash X, returning a value that fits into a fixnum. */
1308
1309LISP_INLINE EMACS_UINT
1310SXHASH_REDUCE (EMACS_UINT x)
1311{
1312 return (x ^ x >> (BITS_PER_EMACS_INT - FIXNUM_BITS)) & INTMASK;
1313}
1314
1307/* These structures are used for various misc types. */ 1315/* These structures are used for various misc types. */
1308 1316
1309struct Lisp_Misc_Any /* Supertype of all Misc types. */ 1317struct Lisp_Misc_Any /* Supertype of all Misc types. */