From aa752ffb9f2b331a29dcddd634b217b60b2e6090 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sun, 29 Mar 2009 15:00:14 +0200 Subject: optimize set_labels() --- src/GipfelWidget.cxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index e334484..e30443c 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -355,7 +355,7 @@ GipfelWidget::set_labels(Hills *v) { m->label_x = (int) fl_width(m->name) + 1; m->label_y = 0; - for (int j = 0; j < i; j++) { + for (int j = i; j > 0; j--) { Hill *n = v->get(j); if (n->flags & (Hill::DUPLICATE | Hill::TRACK_POINT)) @@ -364,9 +364,10 @@ GipfelWidget::set_labels(Hills *v) { if (!show_hidden && (n->flags & Hill::HIDDEN)) continue; - if (overlap(m->x, m->label_x, - n->x - CROSS_SIZE, n->label_x + CROSS_SIZE)) + if (overlap(m->x, m->label_x, n->x - CROSS_SIZE, n->label_x)) colliding.add(n); + else + break; } colliding.sort(Hills::SORT_LABEL_Y); -- cgit v1.2.3