[gtk+] Use a better hash for arcs
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Use a better hash for arcs
- Date: Sun, 1 May 2016 05:12:20 +0000 (UTC)
commit 417eb0ad9c3d32b9398d0b27e55ea48b8e399732
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Apr 30 22:39:26 2016 -0400
Use a better hash for arcs
gtk/gtkroundedbox.c | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkroundedbox.c b/gtk/gtkroundedbox.c
index 67aed7a..a6d9019 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]