Skip to content

Commit

Permalink
swiss: don't put the bucket size check in a function
Browse files Browse the repository at this point in the history
  • Loading branch information
zephyrtronium authored and petermattis committed Feb 28, 2024
1 parent c31b07c commit f89e8e3
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions map.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,14 @@ const (
// The default maximum capacity a bucket is allowed to grow to before it
// will be split.
defaultMaxBucketCapacity uint32 = 4096

expectedBucketSize = ptrSize + 6*4
)

func _() {
// Don't add fields to the bucket unnecessarily. It is packed for
// efficiency so that we can fit 2 buckets into a 64-byte cache line on
// 64-bit architectures.
// This will cause a type error if the size changes.
const expectedSize = ptrSize + 6*4
var _ [0]struct{} = [unsafe.Sizeof(bucket[int, int]{}) - expectedSize]struct{}{}
}
// Don't add fields to the bucket unnecessarily. It is packed for efficiency so
// that we can fit 2 buckets into a 64-byte cache line on 64-bit architectures.
// This will cause a type error if the size of a bucket changes.
var _ [0]struct{} = [unsafe.Sizeof(bucket[int, int]{}) - expectedBucketSize]struct{}{}

// slot holds a key and value.
type slot[K comparable, V any] struct {
Expand Down

0 comments on commit f89e8e3

Please sign in to comment.