mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-31 15:06:26 +00:00
wip
This commit is contained in:
parent
0c6ce34295
commit
d8026dad3c
1 changed files with 10 additions and 0 deletions
10
lib/slicesutil/slicesutil.go
Normal file
10
lib/slicesutil/slicesutil.go
Normal file
|
@ -0,0 +1,10 @@
|
|||
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]
|
||||
}
|
Loading…
Reference in a new issue