Debian Codegraph @

benchmarks/medium_payload_easyjson.go

raw
1 // Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.
2
3 package benchmark
4
5 import (
6 json "encoding/json"
7 easyjson "github.com/mailru/easyjson"
8 jlexer "github.com/mailru/easyjson/jlexer"
9 jwriter "github.com/mailru/easyjson/jwriter"
10 )
11
12 // suppress unused package warning
13 var (
14 _ *json.RawMessage
15 _ *jlexer.Lexer
16 _ *jwriter.Writer
17 _ easyjson.Marshaler
18 )
19
20 func easyjson8ca7813eDecodeBenchmark(in *jlexer.Lexer, out *MediumPayloadEasyJson) {
21 isTopLevel := in.IsStart()
22 if in.IsNull() {
23 if isTopLevel {
24 in.Consumed()
25 }
26 in.Skip()
27 return
28 }
29 in.Delim('{')
30 for !in.IsDelim('}') {
31 key := in.UnsafeString()
32 in.WantColon()
33 if in.IsNull() {
34 in.Skip()
35 in.WantComma()
36 continue
37 }
38 switch key {
39 case "person":
40 if in.IsNull() {
41 in.Skip()
42 out.Person = nil
43 } else {
44 if out.Person == nil {
45 out.Person = new(CBPerson)
46 }
47 easyjson8ca7813eDecodeBenchmark1(in, out.Person)
48 }
49 case "company":
50 out.Company = string(in.String())
51 default:
52 in.SkipRecursive()
53 }
54 in.WantComma()
55 }
56 in.Delim('}')
57 if isTopLevel {
58 in.Consumed()
59 }
60 }
61 func easyjson8ca7813eEncodeBenchmark(out *jwriter.Writer, in MediumPayloadEasyJson) {
62 out.RawByte('{')
63 first := true
64 _ = first
65 {
66 const prefix string = ",\"person\":"
67 if first {
68 first = false
69 out.RawString(prefix[1:])
70 } else {
71 out.RawString(prefix)
72 }
73 if in.Person == nil {
74 out.RawString("null")
75 } else {
76 easyjson8ca7813eEncodeBenchmark1(out, *in.Person)
77 }
78 }
79 {
80 const prefix string = ",\"company\":"
81 if first {
82 first = false
83 out.RawString(prefix[1:])
84 } else {
85 out.RawString(prefix)
86 }
87 out.String(string(in.Company))
88 }
89 out.RawByte('}')
90 }
91
92 // MarshalJSON supports json.Marshaler interface
93 func (v MediumPayloadEasyJson) MarshalJSON() ([]byte, error) {
94 w := jwriter.Writer{}
95 easyjson8ca7813eEncodeBenchmark(&w, v)
96 return w.Buffer.BuildBytes(), w.Error
97 }
98
99 // MarshalEasyJSON supports easyjson.Marshaler interface
100 func (v MediumPayloadEasyJson) MarshalEasyJSON(w *jwriter.Writer) {
101 easyjson8ca7813eEncodeBenchmark(w, v)
102 }
103
104 // UnmarshalJSON supports json.Unmarshaler interface
105 func (v *MediumPayloadEasyJson) UnmarshalJSON(data []byte) error {
106 r := jlexer.Lexer{Data: data}
107 easyjson8ca7813eDecodeBenchmark(&r, v)
108 return r.Error()
109 }
110
111 // UnmarshalEasyJSON supports easyjson.Unmarshaler interface
112 func (v *MediumPayloadEasyJson) UnmarshalEasyJSON(l *jlexer.Lexer) {
113 easyjson8ca7813eDecodeBenchmark(l, v)
114 }
115 func easyjson8ca7813eDecodeBenchmark1(in *jlexer.Lexer, out *CBPerson) {
116 isTopLevel := in.IsStart()
117 if in.IsNull() {
118 if isTopLevel {
119 in.Consumed()
120 }
121 in.Skip()
122 return
123 }
124 in.Delim('{')
125 for !in.IsDelim('}') {
126 key := in.UnsafeString()
127 in.WantColon()
128 if in.IsNull() {
129 in.Skip()
130 in.WantComma()
131 continue
132 }
133 switch key {
134 case "name":
135 if in.IsNull() {
136 in.Skip()
137 out.Name = nil
138 } else {
139 if out.Name == nil {
140 out.Name = new(CBName)
141 }
142 easyjson8ca7813eDecodeBenchmark2(in, out.Name)
143 }
144 case "github":
145 if in.IsNull() {
146 in.Skip()
147 out.Github = nil
148 } else {
149 if out.Github == nil {
150 out.Github = new(CBGithub)
151 }
152 easyjson8ca7813eDecodeBenchmark3(in, out.Github)
153 }
154 case "Gravatar":
155 if in.IsNull() {
156 in.Skip()
157 out.Gravatar = nil
158 } else {
159 if out.Gravatar == nil {
160 out.Gravatar = new(CBGravatar)
161 }
162 easyjson8ca7813eDecodeBenchmark4(in, out.Gravatar)
163 }
164 default:
165 in.SkipRecursive()
166 }
167 in.WantComma()
168 }
169 in.Delim('}')
170 if isTopLevel {
171 in.Consumed()
172 }
173 }
174 func easyjson8ca7813eEncodeBenchmark1(out *jwriter.Writer, in CBPerson) {
175 out.RawByte('{')
176 first := true
177 _ = first
178 {
179 const prefix string = ",\"name\":"
180 if first {
181 first = false
182 out.RawString(prefix[1:])
183 } else {
184 out.RawString(prefix)
185 }
186 if in.Name == nil {
187 out.RawString("null")
188 } else {
189 easyjson8ca7813eEncodeBenchmark2(out, *in.Name)
190 }
191 }
192 {
193 const prefix string = ",\"github\":"
194 if first {
195 first = false
196 out.RawString(prefix[1:])
197 } else {
198 out.RawString(prefix)
199 }
200 if in.Github == nil {
201 out.RawString("null")
202 } else {
203 easyjson8ca7813eEncodeBenchmark3(out, *in.Github)
204 }
205 }
206 {
207 const prefix string = ",\"Gravatar\":"
208 if first {
209 first = false
210 out.RawString(prefix[1:])
211 } else {
212 out.RawString(prefix)
213 }
214 if in.Gravatar == nil {
215 out.RawString("null")
216 } else {
217 easyjson8ca7813eEncodeBenchmark4(out, *in.Gravatar)
218 }
219 }
220 out.RawByte('}')
221 }
222 func easyjson8ca7813eDecodeBenchmark4(in *jlexer.Lexer, out *CBGravatar) {
223 isTopLevel := in.IsStart()
224 if in.IsNull() {
225 if isTopLevel {
226 in.Consumed()
227 }
228 in.Skip()
229 return
230 }
231 in.Delim('{')
232 for !in.IsDelim('}') {
233 key := in.UnsafeString()
234 in.WantColon()
235 if in.IsNull() {
236 in.Skip()
237 in.WantComma()
238 continue
239 }
240 switch key {
241 case "Avatars":
242 if in.IsNull() {
243 in.Skip()
244 out.Avatars = nil
245 } else {
246 in.Delim('[')
247 if out.Avatars == nil {
248 if !in.IsDelim(']') {
249 out.Avatars = make(Avatars, 0, 8)
250 } else {
251 out.Avatars = Avatars{}
252 }
253 } else {
254 out.Avatars = (out.Avatars)[:0]
255 }
256 for !in.IsDelim(']') {
257 var v1 *CBAvatar
258 if in.IsNull() {
259 in.Skip()
260 v1 = nil
261 } else {
262 if v1 == nil {
263 v1 = new(CBAvatar)
264 }
265 easyjson8ca7813eDecodeBenchmark5(in, v1)
266 }
267 out.Avatars = append(out.Avatars, v1)
268 in.WantComma()
269 }
270 in.Delim(']')
271 }
272 default:
273 in.SkipRecursive()
274 }
275 in.WantComma()
276 }
277 in.Delim('}')
278 if isTopLevel {
279 in.Consumed()
280 }
281 }
282 func easyjson8ca7813eEncodeBenchmark4(out *jwriter.Writer, in CBGravatar) {
283 out.RawByte('{')
284 first := true
285 _ = first
286 {
287 const prefix string = ",\"Avatars\":"
288 if first {
289 first = false
290 out.RawString(prefix[1:])
291 } else {
292 out.RawString(prefix)
293 }
294 if in.Avatars == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
295 out.RawString("null")
296 } else {
297 out.RawByte('[')
298 for v2, v3 := range in.Avatars {
299 if v2 > 0 {
300 out.RawByte(',')
301 }
302 if v3 == nil {
303 out.RawString("null")
304 } else {
305 easyjson8ca7813eEncodeBenchmark5(out, *v3)
306 }
307 }
308 out.RawByte(']')
309 }
310 }
311 out.RawByte('}')
312 }
313 func easyjson8ca7813eDecodeBenchmark5(in *jlexer.Lexer, out *CBAvatar) {
314 isTopLevel := in.IsStart()
315 if in.IsNull() {
316 if isTopLevel {
317 in.Consumed()
318 }
319 in.Skip()
320 return
321 }
322 in.Delim('{')
323 for !in.IsDelim('}') {
324 key := in.UnsafeString()
325 in.WantColon()
326 if in.IsNull() {
327 in.Skip()
328 in.WantComma()
329 continue
330 }
331 switch key {
332 case "Url":
333 out.Url = string(in.String())
334 default:
335 in.SkipRecursive()
336 }
337 in.WantComma()
338 }
339 in.Delim('}')
340 if isTopLevel {
341 in.Consumed()
342 }
343 }
344 func easyjson8ca7813eEncodeBenchmark5(out *jwriter.Writer, in CBAvatar) {
345 out.RawByte('{')
346 first := true
347 _ = first
348 {
349 const prefix string = ",\"Url\":"
350 if first {
351 first = false
352 out.RawString(prefix[1:])
353 } else {
354 out.RawString(prefix)
355 }
356 out.String(string(in.Url))
357 }
358 out.RawByte('}')
359 }
360 func easyjson8ca7813eDecodeBenchmark3(in *jlexer.Lexer, out *CBGithub) {
361 isTopLevel := in.IsStart()
362 if in.IsNull() {
363 if isTopLevel {
364 in.Consumed()
365 }
366 in.Skip()
367 return
368 }
369 in.Delim('{')
370 for !in.IsDelim('}') {
371 key := in.UnsafeString()
372 in.WantColon()
373 if in.IsNull() {
374 in.Skip()
375 in.WantComma()
376 continue
377 }
378 switch key {
379 case "Followers":
380 out.Followers = int(in.Int())
381 default:
382 in.SkipRecursive()
383 }
384 in.WantComma()
385 }
386 in.Delim('}')
387 if isTopLevel {
388 in.Consumed()
389 }
390 }
391 func easyjson8ca7813eEncodeBenchmark3(out *jwriter.Writer, in CBGithub) {
392 out.RawByte('{')
393 first := true
394 _ = first
395 {
396 const prefix string = ",\"Followers\":"
397 if first {
398 first = false
399 out.RawString(prefix[1:])
400 } else {
401 out.RawString(prefix)
402 }
403 out.Int(int(in.Followers))
404 }
405 out.RawByte('}')
406 }
407 func easyjson8ca7813eDecodeBenchmark2(in *jlexer.Lexer, out *CBName) {
408 isTopLevel := in.IsStart()
409 if in.IsNull() {
410 if isTopLevel {
411 in.Consumed()
412 }
413 in.Skip()
414 return
415 }
416 in.Delim('{')
417 for !in.IsDelim('}') {
418 key := in.UnsafeString()
419 in.WantColon()
420 if in.IsNull() {
421 in.Skip()
422 in.WantComma()
423 continue
424 }
425 switch key {
426 case "fullName":
427 out.FullName = string(in.String())
428 default:
429 in.SkipRecursive()
430 }
431 in.WantComma()
432 }
433 in.Delim('}')
434 if isTopLevel {
435 in.Consumed()
436 }
437 }
438 func easyjson8ca7813eEncodeBenchmark2(out *jwriter.Writer, in CBName) {
439 out.RawByte('{')
440 first := true
441 _ = first
442 {
443 const prefix string = ",\"fullName\":"
444 if first {
445 first = false
446 out.RawString(prefix[1:])
447 } else {
448 out.RawString(prefix)
449 }
450 out.String(string(in.FullName))
451 }
452 out.RawByte('}')
453 }