graph: cleanup tooltip alias handling
[fio.git] / graph.c
diff --git a/graph.c b/graph.c
index 84bc9f9b3e83bd75c195340870aac008af4d57fe..2f00dab4361d4280f48da66c9a84102ee173b82b 100644 (file)
--- a/graph.c
+++ b/graph.c
@@ -690,23 +690,19 @@ static void graph_label_add_value(struct graph_label *i, void *value,
        x = malloc(sizeof(*x));
        memset(x, 0, sizeof(*x));
        x->value = value;
-       if (tooltip)
-               x->tooltip = strdup(tooltip);
-       else
-               x->tooltip = NULL;
        x->next = NULL;
-       if (!i->tail) {
+       if (!i->tail)
                i->values = x;
-       } else {
+       else
                i->tail->next = x;
-       }
        i->tail = x;
        i->value_count++;
 
-       if (x->tooltip) {
+       if (tooltip) {
                double yval = gety(x);
                double miny = yval / TOOLTIP_DELTA;
                double maxy = yval * TOOLTIP_DELTA;
+               struct prio_tree_node *ret;
 
                INIT_PRIO_TREE_NODE(&x->node);
                x->node.start = miny;
@@ -714,8 +710,15 @@ static void graph_label_add_value(struct graph_label *i, void *value,
                if (x->node.last == x->node.start)
                        x->node.last++;
 
-               prio_tree_insert(&i->prio_tree, &x->node);
-               i->tooltip_count++;
+               /*
+                * If ret != &x->node, we have an alias. Since the values
+                * should be identical, we can drop it
+                */
+               ret = prio_tree_insert(&i->prio_tree, &x->node);
+               if (ret == &x->node) {
+                       x->tooltip = strdup(tooltip);
+                       i->tooltip_count++;
+               }
        }
 
        if (i->parent->per_label_limit != -1 &&