pdata/internal/proto/size.go
raw| 1 | // Copyright The OpenTelemetry Authors |
| 2 | // SPDX-License-Identifier: Apache-2.0 |
| 3 | |
| 4 | package proto // import "go.opentelemetry.io/collector/pdata/internal/proto" |
| 5 | |
| 6 | import ( |
| 7 | "math/bits" |
| 8 | ) |
| 9 | |
| 10 | func Sov(x uint64) (n int) { |
| 11 | return (bits.Len64(x|1) + 6) / 7 |
| 12 | } |
| 13 | |
| 14 | func Soz(x uint64) (n int) { |
| 15 | return Sov((x << 1) ^ uint64((int64(x) >> 63))) |
| 16 | } |