summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2019-06-07 16:39:22 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2019-06-07 16:48:56 -0700
commitde46a6a4484750b96d6bf43c618029fa70db6080 (patch)
treebe2b8c36737677db418c766cfba69e14a46290d3
parentda1974fabddda6fac029db6960110001c6472ddc (diff)
downloademacs-de46a6a4484750b96d6bf43c618029fa70db6080.tar.gz
Use machine pointer width for face hashes
* src/dispextern.h (struct face): * src/xfaces.c (hash_string_case_insensitive, lface_hash) (cache_face, lookup_face): Use uintptr_t for face hashes instead of discarding the upper pointer bits on 64-bit machines.
-rw-r--r--src/dispextern.h2
-rw-r--r--src/xfaces.c14
2 files changed, 7 insertions, 9 deletions
diff --git a/src/dispextern.h b/src/dispextern.h
index cc15950d5df..9ba8e746b22 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1739,7 +1739,7 @@ struct face
#endif
/* The hash value of this face. */
- unsigned hash;
+ uintptr_t hash;
/* Next and previous face in hash collision list of face cache. */
struct face *next, *prev;
diff --git a/src/xfaces.c b/src/xfaces.c
index d211ec8c460..f90e840717c 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -4014,11 +4014,11 @@ For internal use only. */)
/* Return a hash code for Lisp string STRING with case ignored. Used
below in computing a hash value for a Lisp face. */
-static unsigned
+static uintptr_t
hash_string_case_insensitive (Lisp_Object string)
{
const unsigned char *s;
- unsigned hash = 0;
+ uintptr_t hash = 0;
eassert (STRINGP (string));
for (s = SDATA (string); *s; ++s)
hash = (hash << 1) ^ c_tolower (*s);
@@ -4028,7 +4028,7 @@ hash_string_case_insensitive (Lisp_Object string)
/* Return a hash code for face attribute vector V. */
-static unsigned
+static uintptr_t
lface_hash (Lisp_Object *v)
{
return (hash_string_case_insensitive (v[LFACE_FAMILY_INDEX])
@@ -4370,7 +4370,7 @@ free_face_cache (struct face_cache *c)
that a requested face is not cached. */
static void
-cache_face (struct face_cache *c, struct face *face, unsigned int hash)
+cache_face (struct face_cache *c, struct face *face, uintptr_t hash)
{
int i = hash % FACE_CACHE_BUCKETS_SIZE;
@@ -4467,16 +4467,14 @@ static int
lookup_face (struct frame *f, Lisp_Object *attr)
{
struct face_cache *cache = FRAME_FACE_CACHE (f);
- unsigned hash;
- int i;
struct face *face;
eassert (cache != NULL);
check_lface_attrs (attr);
/* Look up ATTR in the face cache. */
- hash = lface_hash (attr);
- i = hash % FACE_CACHE_BUCKETS_SIZE;
+ uintptr_t hash = lface_hash (attr);
+ int i = hash % FACE_CACHE_BUCKETS_SIZE;
for (face = cache->buckets[i]; face; face = face->next)
{