From 73b463e814db41fd3f9a9c2aac7be8a86a6e9522 Mon Sep 17 00:00:00 2001 From: "Matt T. Proud" Date: Mon, 18 Mar 2013 12:26:45 -0700 Subject: [PATCH] Additional simplifications. --- storage/metric/operation.go | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/storage/metric/operation.go b/storage/metric/operation.go index 24abaef527..a090a00c78 100644 --- a/storage/metric/operation.go +++ b/storage/metric/operation.go @@ -404,15 +404,12 @@ func optimizeForward(pending ops) (out ops) { from = next.from ) - for { + for !from.After(next.through) { from = from.Add(t.interval) - - if from.After(next.through) { - after.from = from - break - } } + after.from = from + pending = append(ops{&before, &after}, pending...) sort.Sort(startsAtSort{pending}) @@ -451,17 +448,15 @@ func optimizeForward(pending ops) (out ops) { if next.GreedierThan(t) { var ( - t = next.from + nextStart = next.from ) - for { - t = t.Add(next.interval) - if t.After(next.through) { - next.from = t - - tail = append(ops{next}, pending...) - } + for !nextStart.After(next.through) { + nextStart = nextStart.Add(next.interval) } + + next.from = nextStart + tail = append(ops{next}, pending...) } default: panic("unknown operation type")