From 4a6985ca270f29695f24064a0c4dd7952f3c8050 Mon Sep 17 00:00:00 2001 From: Ali Gholami Rudi Date: Mon, 8 Nov 2010 23:06:28 +0330 Subject: [PATCH] pad: a better hash function --- pad.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pad.c b/pad.c index 685af06..6eb2452 100644 --- a/pad.c +++ b/pad.c @@ -48,7 +48,7 @@ static fbval_t color2fb(int c) return fb_color(CR(cd[c]), CG(cd[c]), CB(cd[c])); } -#define NCACHE ((1 << 11) - 1) +#define NCACHE (1 << 11) static fbval_t cache[NCACHE * MAXDOTS]; static struct glyph { int c; @@ -57,7 +57,7 @@ static struct glyph { static int glyph_hash(struct glyph *g) { - return (g->c | (((g->fg + 1) ^ g->bg) << 7)) % NCACHE; + return (g->c ^ (g->fg << 7) ^ (g->bg << 6)) & (NCACHE - 1); } static fbval_t *bitmap(int c, short fg, short bg) -- 2.11.4.GIT