extractValuesAroundTime() code simplification.

This commit is contained in:
Julius Volz 2013-05-21 23:20:43 +02:00 committed by Julius Volz
parent 008314b5a8
commit 83d60bed89

View file

@ -111,14 +111,14 @@ func extractValuesAroundTime(t time.Time, in model.Values) (out model.Values) {
if in[i].Timestamp.Equal(t) && len(in) > i+1 {
// We hit exactly the current sample time. Very unlikely in practice.
// Return only the current sample.
out = append(out, in[i])
out = in[i : i+1]
} else {
if i == 0 {
// We hit before the first sample time. Return only the first sample.
out = append(out, in[0:1]...)
out = in[0:1]
} else {
// We hit between two samples. Return both surrounding samples.
out = append(out, in[i-1:i+1]...)
out = in[i-1 : i+1]
}
}
}