aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--trace-graph.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/trace-graph.c b/trace-graph.c
index 8692fe7..b70e27d 100644
--- a/trace-graph.c
+++ b/trace-graph.c
@@ -735,27 +735,32 @@ button_release_event(GtkWidget *widget, GdkEventMotion *event, gpointer data)
735 735
736static gint do_hash(gint val) 736static gint do_hash(gint val)
737{ 737{
738 int i, x, y; 738 int hash, tmp;
739 int total = 0;
740 739
740 /* idle always gets black */
741 if (!val) 741 if (!val)
742 return 0; 742 return 0;
743 743
744 for (i = 0; i < 32; i++) { 744 hash = 12546869; /* random prime */
745 y = 0; 745
746 if (val & (1 << i)) { 746 /*
747 for (x = 0; x < ((i+1) * 13); x++) { 747 * The following hash is based off of Paul Hsieh's super fast hash:
748 y |= 1 << ((x * 23) & 31); 748 * http://www.azillionmonkeys.com/qed/hash.html
749 } 749 */
750 } else { 750
751 for (x = 0; x < ((i+1) * 7); x++) { 751 hash += (val & 0xffff);
752 y |= 1 << ((x * 17) & 31); 752 tmp = (val >> 16) ^ hash;
753 } 753 hash = (hash << 16) ^ tmp;
754 } 754 hash += hash >> 11;
755 total += y; 755
756 } 756 hash ^= hash << 3;
757 hash += hash >> 5;
758 hash ^= hash << 4;
759 hash += hash >> 17;
760 hash ^= hash << 25;
761 hash += hash >> 6;
757 762
758 return total; 763 return hash;
759} 764}
760 765
761static void set_color_by_pid(GtkWidget *widget, GdkGC *gc, gint pid) 766static void set_color_by_pid(GtkWidget *widget, GdkGC *gc, gint pid)