Documentation
¶
Index ¶
Constants ¶
const TypeHashMultiplier = 0x9E3779B97F4A7C15
TypeHashMultiplier is the multiplier of the Fibonacci hashing of the address of a type: the top bits of the product spread the addresses, which are aligned and close to each other, over a table.
Variables ¶
var HasAVX2 = detectAVX2()
HasAVX2 is whether the CPU and the OS support AVX2.
Functions ¶
func IfaceIndir ¶
IfaceIndir reports whether a value of the type is stored indirectly in an interface value: the data word of the interface points to a copy of the value, instead of being the value itself.
Which types are stored directly is decided by the compiler and the rule depends on the Go version ( e.g. a struct of a zero-sized field and a pointer is direct since Go 1.26 ), so the rule is not reimplemented here. Instead, a value whose first word is a known pointer is converted to an interface value, and the data word tells how it was stored.
func IsIgnoredStructField ¶
func IsIgnoredStructField(field reflect.StructField) bool
Types ¶
type StructTag ¶
type StructTag struct {
Key string
IsTaggedKey bool
IsOmitEmpty bool
IsString bool
Field reflect.StructField
}
func StructTagFromField ¶
func StructTagFromField(field reflect.StructField) *StructTag
type StructTags ¶
type StructTags []*StructTag
func (StructTags) ExistsKey ¶
func (t StructTags) ExistsKey(key string) bool
type TypeCache ¶ added in v0.11.0
type TypeCache[T any] struct { // contains filtered or unexported fields }
TypeCache is a table of the values for the types, which is looked up by the address of a type without a lock.
It is a hash table with open addressing. It used to be an array which had a slot for every address a type of the program can be at, which was found from the type links of the runtime: that needed a linkname, a scan of every type at the start, memory in proportion to the size of the program, and a fallback for the types which are not in the type links. A lookup of this table costs about the same, and it has none of them.
The zero value is ready to use.