File: elsize_default.go

package info (click to toggle)
golang-github-tinylib-msgp 1.2.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 836 kB
  • sloc: makefile: 47
file content (21 lines) | stat: -rw-r--r-- 410 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//go:build !tinygo
// +build !tinygo

package msgp

// size of every object on the wire,
// plus type information. gives us
// constant-time type information
// for traversing composite objects.
var sizes [256]bytespec

func init() {
	for i := 0; i < 256; i++ {
		sizes[i] = calcBytespec(byte(i))
	}
}

// getBytespec gets inlined to a simple array index
func getBytespec(v byte) bytespec {
	return sizes[v]
}