diff options
author | Matthias Clasen <mclasen@redhat.com> | 2016-04-30 22:39:26 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2016-05-05 15:04:00 -0400 |
commit | 631123bbd44af345724b66b9e7e055188351abde (patch) | |
tree | a336731b9cced9eba9c9feba895014cd4c7b6565 | |
parent | 5f9a19ff33545cc51e87f0ee1fa18ba166b6bae7 (diff) | |
download | gtk+-631123bbd44af345724b66b9e7e055188351abde.tar.gz |
Use a better hash for arcs
-rw-r--r-- | gtk/gtkroundedbox.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/gtk/gtkroundedbox.c b/gtk/gtkroundedbox.c index 67aed7a786..38443d7236 100644 --- a/gtk/gtkroundedbox.c +++ b/gtk/gtkroundedbox.c @@ -228,10 +228,25 @@ typedef struct { gboolean negative; } Arc; +static inline guint +mem_hash (gconstpointer v, gint len) +{ + const signed char *p; + const signed char *end; + guint32 h = 5381; + + p = v; + end = p + len; + for (; p < end; p++) + h = (h << 5) + h + *p; + + return h; +} + static guint arc_path_hash (Arc *arc) { - return g_double_hash (&arc->angle1) ^ g_double_hash (&arc->angle2) ^ arc->negative; + return mem_hash ((gconstpointer)arc, sizeof (Arc)); } static gboolean @@ -263,6 +278,7 @@ append_arc (cairo_t *cr, double angle1, double angle2, gboolean negative) Arc key; cairo_path_t *arc; + memset (&key, 0, sizeof (Arc)); key.angle1 = angle1; key.angle2 = angle2; key.negative = negative; |