[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Fix a hash lookup problem in xfaces.c
From: |
Zhehao Lin |
Subject: |
[PATCH] Fix a hash lookup problem in xfaces.c |
Date: |
Sat, 1 Jan 2022 17:24:27 +0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.1 |
Hello, this patch fixes a problem in the `face_for_font` function in `src/
xfaces.c` where an `unsigned` instead of an `uintptr_t` was used to
store the
computed hash value of the face. If the hash value was too large (>UINT_MAX)
and truncated, the lookup and storing (the latter uses `uintptr_t` as
the rest
of the program does) would happen in different buckets, resulting in
constant
cache misses.
This can cause huge performance impact when `face_for_font' is called really
frequently (for example with ligatures enabled), but for brevity please
allow
me to omit the details here.
Zhehao Lin
From 06caba2dc34d8ffddd9917f0621d31317e899e90 Mon Sep 17 00:00:00 2001
From: Zhehao Lin <zh_lin1@outlook.com>
Date: Sat, 1 Jan 2022 16:19:49 +0800
Subject: [PATCH] * src/xfaces.c: Use uintptr_t instead of unsigned to store
hash value
---
src/xfaces.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/xfaces.c b/src/xfaces.c
index 6f52637e91..ae6143b330 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -4806,7 +4806,7 @@ face_for_font (struct frame *f, Lisp_Object
font_object,
struct face *base_face)
{
struct face_cache *cache = FRAME_FACE_CACHE (f);
- unsigned hash;
+ uintptr_t hash;
int i;
struct face *face;
--
2.34.1
- [PATCH] Fix a hash lookup problem in xfaces.c,
Zhehao Lin <=