forked from alecthomas/go_serialization_benchmarks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
msgp_gen.go
94 lines (89 loc) · 2.24 KB
/
msgp_gen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package goserbench
// NOTE: THIS FILE WAS PRODUCED BY THE
// MSGP CODE GENERATION TOOL (github.com/tinylib/msgp)
// DO NOT EDIT
import "github.com/tinylib/msgp/msgp"
// MarshalMsg implements msgp.Marshaler
func (z *A) MarshalMsg(b []byte) (o []byte, err error) {
o = msgp.Require(b, z.Msgsize())
// map header, size 6
// string "Name"
o = append(o, 0x86, 0xa4, 0x4e, 0x61, 0x6d, 0x65)
o = msgp.AppendString(o, z.Name)
// string "BirthDay"
o = append(o, 0xa8, 0x42, 0x69, 0x72, 0x74, 0x68, 0x44, 0x61, 0x79)
o = msgp.AppendTime(o, z.BirthDay)
// string "Phone"
o = append(o, 0xa5, 0x50, 0x68, 0x6f, 0x6e, 0x65)
o = msgp.AppendString(o, z.Phone)
// string "Siblings"
o = append(o, 0xa8, 0x53, 0x69, 0x62, 0x6c, 0x69, 0x6e, 0x67, 0x73)
o = msgp.AppendInt(o, z.Siblings)
// string "Spouse"
o = append(o, 0xa6, 0x53, 0x70, 0x6f, 0x75, 0x73, 0x65)
o = msgp.AppendBool(o, z.Spouse)
// string "Money"
o = append(o, 0xa5, 0x4d, 0x6f, 0x6e, 0x65, 0x79)
o = msgp.AppendFloat64(o, z.Money)
return
}
// UnmarshalMsg implements msgp.Unmarshaler
func (z *A) UnmarshalMsg(bts []byte) (o []byte, err error) {
var field []byte
_ = field
var xvk uint32
xvk, bts, err = msgp.ReadMapHeaderBytes(bts)
if err != nil {
return
}
for xvk > 0 {
xvk--
field, bts, err = msgp.ReadMapKeyZC(bts)
if err != nil {
return
}
switch msgp.UnsafeString(field) {
case "Name":
z.Name, bts, err = msgp.ReadStringBytes(bts)
if err != nil {
return
}
case "BirthDay":
z.BirthDay, bts, err = msgp.ReadTimeBytes(bts)
if err != nil {
return
}
case "Phone":
z.Phone, bts, err = msgp.ReadStringBytes(bts)
if err != nil {
return
}
case "Siblings":
z.Siblings, bts, err = msgp.ReadIntBytes(bts)
if err != nil {
return
}
case "Spouse":
z.Spouse, bts, err = msgp.ReadBoolBytes(bts)
if err != nil {
return
}
case "Money":
z.Money, bts, err = msgp.ReadFloat64Bytes(bts)
if err != nil {
return
}
default:
bts, err = msgp.Skip(bts)
if err != nil {
return
}
}
}
o = bts
return
}
func (z *A) Msgsize() (s int) {
s = 1 + 5 + msgp.StringPrefixSize + len(z.Name) + 9 + msgp.TimeSize + 6 + msgp.StringPrefixSize + len(z.Phone) + 9 + msgp.IntSize + 7 + msgp.BoolSize + 6 + msgp.Float64Size
return
}