forked from alecthomas/go_serialization_benchmarks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
msgp_gen.go
149 lines (98 loc) · 2.4 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package goserbench
// NOTE: THIS FILE WAS PRODUCED BY THE
// MSGP CODE GENERATION TOOL (github.com/philhofer/msgp)
// DO NOT EDIT
import (
"github.com/philhofer/msgp/msgp"
)
// MarshalMsg implements the msgp.Marshaler interface
func (z *A) MarshalMsg(b []byte) (o []byte, err error) {
o = msgp.Require(b, z.Msgsize())
o = msgp.AppendMapHeader(o, 6)
o = msgp.AppendString(o, "Name")
o = msgp.AppendString(o, z.Name)
o = msgp.AppendString(o, "BirthDay")
o = msgp.AppendTime(o, z.BirthDay)
o = msgp.AppendString(o, "Phone")
o = msgp.AppendString(o, z.Phone)
o = msgp.AppendString(o, "Siblings")
o = msgp.AppendInt(o, z.Siblings)
o = msgp.AppendString(o, "Spouse")
o = msgp.AppendBool(o, z.Spouse)
o = msgp.AppendString(o, "Money")
o = msgp.AppendFloat64(o, z.Money)
return
}
// UnmarshalMsg unmarshals a A from MessagePack, returning any extra bytes
// and any errors encountered
func (z *A) UnmarshalMsg(bts []byte) (o []byte, err error) {
var field []byte
_ = field
var isz uint32
isz, bts, err = msgp.ReadMapHeaderBytes(bts)
if err != nil {
return
}
for xplz := uint32(0); xplz < isz; xplz++ {
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
}
// Msgsize implements the msgp.Sizer interface
func (z *A) Msgsize() (s int) {
s += msgp.MapHeaderSize
s += msgp.StringPrefixSize + 4
s += msgp.StringPrefixSize + len(z.Name)
s += msgp.StringPrefixSize + 8
s += msgp.TimeSize
s += msgp.StringPrefixSize + 5
s += msgp.StringPrefixSize + len(z.Phone)
s += msgp.StringPrefixSize + 8
s += msgp.IntSize
s += msgp.StringPrefixSize + 6
s += msgp.BoolSize
s += msgp.StringPrefixSize + 5
s += msgp.Float64Size
return
}