mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-02 08:31:11 -08:00
extractValuesAroundTime() code simplification.
This commit is contained in:
parent
008314b5a8
commit
83d60bed89
|
@ -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]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue