1
2
3
4
5 package abi
6
7 import (
8 "unsafe"
9 )
10
11
12
13 const (
14
15 SwissMapGroupSlotsBits = 3
16
17
18 SwissMapGroupSlots = 1 << SwissMapGroupSlotsBits
19
20
21
22 SwissMapMaxKeyBytes = 128
23 SwissMapMaxElemBytes = 128
24
25 ctrlEmpty = 0b10000000
26 bitsetLSB = 0x0101010101010101
27
28
29 SwissMapCtrlEmpty = bitsetLSB * uint64(ctrlEmpty)
30 )
31
32 type SwissMapType struct {
33 Type
34 Key *Type
35 Elem *Type
36 Group *Type
37
38 Hasher func(unsafe.Pointer, uintptr) uintptr
39 SlotSize uintptr
40 ElemOff uintptr
41 Flags uint32
42 }
43
44
45 const (
46 SwissMapNeedKeyUpdate = 1 << iota
47 SwissMapHashMightPanic
48 SwissMapIndirectKey
49 SwissMapIndirectElem
50 )
51
52 func (mt *SwissMapType) NeedKeyUpdate() bool {
53 return mt.Flags&SwissMapNeedKeyUpdate != 0
54 }
55 func (mt *SwissMapType) HashMightPanic() bool {
56 return mt.Flags&SwissMapHashMightPanic != 0
57 }
58 func (mt *SwissMapType) IndirectKey() bool {
59 return mt.Flags&SwissMapIndirectKey != 0
60 }
61 func (mt *SwissMapType) IndirectElem() bool {
62 return mt.Flags&SwissMapIndirectElem != 0
63 }
64
View as plain text