emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master de46a6a 1/3: Use machine pointer width for face has


From: Paul Eggert
Subject: [Emacs-diffs] master de46a6a 1/3: Use machine pointer width for face hashes
Date: Fri, 7 Jun 2019 19:49:04 -0400 (EDT)

branch: master
commit de46a6a4484750b96d6bf43c618029fa70db6080
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    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.
---
 src/dispextern.h |  2 +-
 src/xfaces.c     | 14 ++++++--------
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/dispextern.h b/src/dispextern.h
index cc15950..9ba8e74 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 d211ec8..f90e840 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)
     {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]