diff options
| author | Paul Eggert | 2019-06-07 16:39:22 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-06-07 16:48:56 -0700 |
| commit | de46a6a4484750b96d6bf43c618029fa70db6080 (patch) | |
| tree | be2b8c36737677db418c766cfba69e14a46290d3 /src | |
| parent | da1974fabddda6fac029db6960110001c6472ddc (diff) | |
| download | emacs-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.h | 2 | ||||
| -rw-r--r-- | src/xfaces.c | 14 |
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 | ||
| 4017 | static unsigned | 4017 | static uintptr_t |
| 4018 | hash_string_case_insensitive (Lisp_Object string) | 4018 | hash_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 | ||
| 4031 | static unsigned | 4031 | static uintptr_t |
| 4032 | lface_hash (Lisp_Object *v) | 4032 | lface_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 | ||
| 4372 | static void | 4372 | static void |
| 4373 | cache_face (struct face_cache *c, struct face *face, unsigned int hash) | 4373 | cache_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 | |||
| 4467 | lookup_face (struct frame *f, Lisp_Object *attr) | 4467 | lookup_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 | { |