[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r111713: Minor hashing refactoring.
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r111713: Minor hashing refactoring. |
Date: |
Sat, 09 Feb 2013 14:42:33 -0800 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 111713
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Sat 2013-02-09 14:42:33 -0800
message:
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.
modified:
src/ChangeLog
src/fns.c
src/lisp.h
src/profiler.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2013-02-09 16:39:46 +0000
+++ b/src/ChangeLog 2013-02-09 22:42:33 +0000
@@ -1,3 +1,15 @@
+2013-02-09 Paul Eggert <address@hidden>
+
+ 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.
+
2013-02-09 Eli Zaretskii <address@hidden>
* callproc.c (Fcall_process_region) [WINDOWSNT]: Make sure the
=== modified file 'src/fns.c'
--- a/src/fns.c 2013-02-07 16:09:04 +0000
+++ b/src/fns.c 2013-02-09 22:42:33 +0000
@@ -4045,10 +4045,6 @@
#define SXHASH_MAX_LEN 7
-/* Hash X, returning a value that fits into a Lisp integer. */
-#define SXHASH_REDUCE(X) \
- ((((X) ^ (X) >> (BITS_PER_EMACS_INT - FIXNUM_BITS))) & INTMASK)
-
/* Return a hash for string PTR which has length LEN. The hash value
can be any EMACS_UINT value. */
@@ -4081,7 +4077,7 @@
/* Return a hash for the floating point value VAL. */
-static EMACS_INT
+static EMACS_UINT
sxhash_float (double val)
{
EMACS_UINT hash = 0;
=== modified file 'src/lisp.h'
--- a/src/lisp.h 2013-02-08 05:28:52 +0000
+++ b/src/lisp.h 2013-02-09 22:42:33 +0000
@@ -227,7 +227,7 @@
/* Lisp integers use 2 tags, to give them one extra bit, thus
extending their range from, e.g., -2^28..2^28-1 to -2^29..2^29-1. */
-static EMACS_INT const INTMASK = EMACS_INT_MAX >> (INTTYPEBITS - 1);
+#define INTMASK (EMACS_INT_MAX >> (INTTYPEBITS - 1))
#define case_Lisp_Int case Lisp_Int0: case Lisp_Int1
#define LISP_INT_TAG_P(x) (((x) & ~Lisp_Int1) == 0)
@@ -1304,6 +1304,14 @@
return (x << 4) + (x >> (BITS_PER_EMACS_INT - 4)) + y;
}
+/* Hash X, returning a value that fits into a fixnum. */
+
+LISP_INLINE EMACS_UINT
+SXHASH_REDUCE (EMACS_UINT x)
+{
+ return (x ^ x >> (BITS_PER_EMACS_INT - FIXNUM_BITS)) & INTMASK;
+}
+
/* 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 2013-01-02 16:13:04 +0000
+++ b/src/profiler.c 2013-02-09 22:42:33 +0000
@@ -560,7 +560,7 @@
? XHASH (XCDR (XCDR (f))) : XHASH (f));
hash = sxhash_combine (hash, hash1);
}
- return (hash & INTMASK);
+ return SXHASH_REDUCE (hash);
}
else
return XHASH (bt);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r111713: Minor hashing refactoring.,
Paul Eggert <=