vt: utf8: rotate instead of just shifting when updating compose key

This reduces the number of collisions in even more workloads.
This commit is contained in:
Daniel Eklöf 2021-06-24 19:36:39 +02:00
parent 88ce0e4375
commit 3bad062f8a
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

11
vt.c
View file

@ -585,6 +585,13 @@ action_put(struct terminal *term, uint8_t c)
dcs_put(term, c);
}
static inline uint32_t
chain_key(uint32_t old_key, uint32_t new_wc)
{
/* Rotate left 8 bits, xor with new char */
return ((old_key << 8) | (old_key >> (32 - 8))) ^ new_wc;
}
static void
action_utf8_print(struct terminal *term, wchar_t wc)
{
@ -618,8 +625,6 @@ action_utf8_print(struct terminal *term, wchar_t wc)
? composed_lookup(term->composed, base - CELL_COMB_CHARS_LO)
: NULL;
#define chain_key(old, new) (((old) << 8) ^ (new))
uint32_t key;
if (composed != NULL) {
@ -629,8 +634,6 @@ action_utf8_print(struct terminal *term, wchar_t wc)
} else
key = chain_key(base, wc);
#undef chain_key
key &= CELL_COMB_CHARS_HI - CELL_COMB_CHARS_LO;
#if defined(FOOT_GRAPHEME_CLUSTERING)