aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2019-06-07 16:39:22 -0700
committerPaul Eggert2019-06-07 16:48:56 -0700
commitde46a6a4484750b96d6bf43c618029fa70db6080 (patch)
treebe2b8c36737677db418c766cfba69e14a46290d3 /src
parentda1974fabddda6fac029db6960110001c6472ddc (diff)
downloademacs-de46a6a4484750b96d6bf43c618029fa70db6080.tar.gz
emacs-de46a6a4484750b96d6bf43c618029fa70db6080.zip
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.
Diffstat (limited to 'src')
-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
1739#endif 1739#endif
1740 1740
1741 /* The hash value of this face. */ 1741 /* The hash value of this face. */
1742 unsigned hash; 1742 uintptr_t hash;
1743 1743
1744 /* Next and previous face in hash collision list of face cache. */ 1744 /* Next and previous face in hash collision list of face cache. */
1745 struct face *next, *prev; 1745 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. */)
4014/* Return a hash code for Lisp string STRING with case ignored. Used 4014/* Return a hash code for Lisp string STRING with case ignored. Used
4015 below in computing a hash value for a Lisp face. */ 4015 below in computing a hash value for a Lisp face. */
4016 4016
4017static unsigned 4017static uintptr_t
4018hash_string_case_insensitive (Lisp_Object string) 4018hash_string_case_insensitive (Lisp_Object string)
4019{ 4019{
4020 const unsigned char *s; 4020 const unsigned char *s;
4021 unsigned hash = 0; 4021 uintptr_t hash = 0;
4022 eassert (STRINGP (string)); 4022 eassert (STRINGP (string));
4023 for (s = SDATA (string); *s; ++s) 4023 for (s = SDATA (string); *s; ++s)
4024 hash = (hash << 1) ^ c_tolower (*s); 4024 hash = (hash << 1) ^ c_tolower (*s);
@@ -4028,7 +4028,7 @@ hash_string_case_insensitive (Lisp_Object string)
4028 4028
4029/* Return a hash code for face attribute vector V. */ 4029/* Return a hash code for face attribute vector V. */
4030 4030
4031static unsigned 4031static uintptr_t
4032lface_hash (Lisp_Object *v) 4032lface_hash (Lisp_Object *v)
4033{ 4033{
4034 return (hash_string_case_insensitive (v[LFACE_FAMILY_INDEX]) 4034 return (hash_string_case_insensitive (v[LFACE_FAMILY_INDEX])
@@ -4370,7 +4370,7 @@ free_face_cache (struct face_cache *c)
4370 that a requested face is not cached. */ 4370 that a requested face is not cached. */
4371 4371
4372static void 4372static void
4373cache_face (struct face_cache *c, struct face *face, unsigned int hash) 4373cache_face (struct face_cache *c, struct face *face, uintptr_t hash)
4374{ 4374{
4375 int i = hash % FACE_CACHE_BUCKETS_SIZE; 4375 int i = hash % FACE_CACHE_BUCKETS_SIZE;
4376 4376
@@ -4467,16 +4467,14 @@ static int
4467lookup_face (struct frame *f, Lisp_Object *attr) 4467lookup_face (struct frame *f, Lisp_Object *attr)
4468{ 4468{
4469 struct face_cache *cache = FRAME_FACE_CACHE (f); 4469 struct face_cache *cache = FRAME_FACE_CACHE (f);
4470 unsigned hash;
4471 int i;
4472 struct face *face; 4470 struct face *face;
4473 4471
4474 eassert (cache != NULL); 4472 eassert (cache != NULL);
4475 check_lface_attrs (attr); 4473 check_lface_attrs (attr);
4476 4474
4477 /* Look up ATTR in the face cache. */ 4475 /* Look up ATTR in the face cache. */
4478 hash = lface_hash (attr); 4476 uintptr_t hash = lface_hash (attr);
4479 i = hash % FACE_CACHE_BUCKETS_SIZE; 4477 int i = hash % FACE_CACHE_BUCKETS_SIZE;
4480 4478
4481 for (face = cache->buckets[i]; face; face = face->next) 4479 for (face = cache->buckets[i]; face; face = face->next)
4482 { 4480 {