Use cap to determine slice capacity

Signed-off-by: Filip Petkovski <filip.petkovsky@gmail.com>
This commit is contained in:
Filip Petkovski 2023-12-08 10:12:50 +01:00
parent 10a82f87fd
commit 9008271df5
No known key found for this signature in database
GPG key ID: 431B0F2E85E42402

View file

@ -321,7 +321,7 @@ func (h *Histogram) ToFloat(fh *FloatHistogram) *FloatHistogram {
}
func resize[T any](items []T, n int) []T {
if len(items) < n {
if cap(items) < n {
return make([]T, n)
}
return items[:n]