Files
chronical/vendor/github.com/valyala/fasthttp/round2_32.go
William Gill caab555275
Some checks failed
Create Release & Upload Assets / Upload Assets To Gitea w/ goreleaser (push) Successful in 2m3s
Create Release & Upload Assets / Build Container Image (push) Failing after 1m6s
Puuuussshhh
2025-10-11 03:41:01 +00:00

31 lines
503 B
Go

//go:build !amd64 && !arm64 && !ppc64 && !ppc64le && !s390x
package fasthttp
import "math"
func roundUpForSliceCap(n int) int {
if n <= 0 {
return 0
}
// Above 100MB, we don't round up as the overhead is too large.
if n > 100*1024*1024 {
return n
}
x := uint32(n - 1)
x |= x >> 1
x |= x >> 2
x |= x >> 4
x |= x >> 8
x |= x >> 16
// Make sure we don't return 0 due to overflow, even on 32 bit systems
if x >= uint32(math.MaxInt32) {
return math.MaxInt32
}
return int(x + 1)
}