summaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-09-07 16:38:22 -0700
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-09-07 16:38:22 -0700
commit11641095ae36518e801109a8f1d8273110f200b8 (patch)
tree08b26508e8d54b2a5fbaa1caba8f17e9c3b47ebf /profile.c
parent95a051e16410f95e936bd6746b4cf9775ab81773 (diff)
downloadsubsurface-11641095ae36518e801109a8f1d8273110f200b8.tar.gz
Turn tail recursion back into a loop
I still think there should be some way to partition the space automatically, but the algorithm that worked best was the simple tail-recursive one. Which might as well be expressed as a loop. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/profile.c b/profile.c
index 706f60ba0..29874d9c6 100644
--- a/profile.c
+++ b/profile.c
@@ -95,7 +95,7 @@ static void plot_text(struct graphics_context *gc, text_render_options_t *tro,
}
/*
- * Find the next maximum point in a 10-minute window.
+ * Find the next minimum/maximum point.
*
* We exit early if we hit "enough" of a depth reversal,
* which is roughly 10 feet.
@@ -164,21 +164,16 @@ static void render_depth_sample(struct graphics_context *gc, struct sample *samp
static void plot_text_samples(struct graphics_context *gc, struct sample *a, struct sample *b)
{
- struct sample *max, *min;
-
- if (b <= a)
- return;
- if (b[-1].time.seconds - a->time.seconds < 3*60)
- return;
-
- max = next_minmax(a, b, 1);
- if (max) {
- render_depth_sample(gc, max);
- min = next_minmax(max, b, 0);
- if (min) {
- plot_text_samples(gc, min, b);
+ for (;;) {
+ if (b <= a)
+ break;
+ a = next_minmax(a, b, 1);
+ if (!a)
return;
- }
+ render_depth_sample(gc, a);
+ a = next_minmax(a, b, 0);
+ if (!a)
+ break;
}
}