mirror of
https://github.com/prometheus/prometheus.git
synced 2026-02-18 18:25:24 -05:00
promql: Preallocate slice in extendFloats
Signed-off-by: Rushabh Mehta <mehtarushabh2005@gmail.com>
This commit is contained in:
parent
48e6f6a751
commit
fc330642e4
1 changed files with 3 additions and 3 deletions
|
|
@ -4418,9 +4418,9 @@ func extendFloats(floats []FPoint, mint, maxt int64, smoothed bool) []FPoint {
|
|||
lastSampleIndex--
|
||||
}
|
||||
|
||||
// TODO: Preallocate the length of the new list.
|
||||
out := make([]FPoint, 0)
|
||||
// Create the new floats list with the boundary samples and the inner samples.
|
||||
count := max(lastSampleIndex-firstSampleIndex+1, 0)
|
||||
out := make([]FPoint, 0, count+2)
|
||||
|
||||
out = append(out, FPoint{T: mint, F: left})
|
||||
out = append(out, floats[firstSampleIndex:lastSampleIndex+1]...)
|
||||
out = append(out, FPoint{T: maxt, F: right})
|
||||
|
|
|
|||
Loading…
Reference in a new issue