MCPcopy
hub / github.com/syncthing/syncthing / getBucketForLen

Function getBucketForLen

lib/protocol/bufferpool.go:79–87  ·  view source on GitHub ↗

getBucketForLen returns the bucket where we should get a slice of a certain length. Each bucket is guaranteed to hold slices that are precisely the block size for that bucket, so if the block size is larger than our size we are good.

(len int)

Source from the content-addressed store, hash-verified

77// precisely the block size for that bucket, so if the block size is larger
78// than our size we are good.
79func getBucketForLen(len int) int {
80 for i, blockSize := range BlockSizes {
81 if len <= blockSize {
82 return i
83 }
84 }
85
86 panic(fmt.Sprintf("bug: tried to get impossible block len %d", len))
87}
88
89// putBucketForCap returns the bucket where we should put a slice of a
90// certain capacity. Each bucket is guaranteed to hold slices that are

Callers 2

TestGetBucketNumbersFunction · 0.85
GetMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestGetBucketNumbersFunction · 0.68