mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-31 15:06:26 +00:00
10 lines
261 B
Go
10 lines
261 B
Go
package slicesutil
|
|
|
|
// ExtendCapacity returns a with the capacity extended to len(a)+n if needed.
|
|
func ExtendCapacity[T any](a []T, n int) []T {
|
|
aLen := len(a)
|
|
if n := aLen + n - cap(a); n > 0 {
|
|
a = append(a[:cap(a)], make([]T, n)...)
|
|
}
|
|
return a[:aLen]
|
|
}
|