| 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 easyjsonD519278DecodeBenchmark(in *jlexer.Lexer, out *LargePayloadEasyJson) { |
| 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 "Users": |
| 40 |
if in.IsNull() { |
| 41 |
in.Skip() |
| 42 |
out.Users = nil |
| 43 |
} else { |
| 44 |
in.Delim('[') |
| 45 |
if out.Users == nil { |
| 46 |
if !in.IsDelim(']') { |
| 47 |
out.Users = make(DSUsers, 0, 8) |
| 48 |
} else { |
| 49 |
out.Users = DSUsers{} |
| 50 |
} |
| 51 |
} else { |
| 52 |
out.Users = (out.Users)[:0] |
| 53 |
} |
| 54 |
for !in.IsDelim(']') { |
| 55 |
var v1 *DSUser |
| 56 |
if in.IsNull() { |
| 57 |
in.Skip() |
| 58 |
v1 = nil |
| 59 |
} else { |
| 60 |
if v1 == nil { |
| 61 |
v1 = new(DSUser) |
| 62 |
} |
| 63 |
easyjsonD519278DecodeBenchmark1(in, v1) |
| 64 |
} |
| 65 |
out.Users = append(out.Users, v1) |
| 66 |
in.WantComma() |
| 67 |
} |
| 68 |
in.Delim(']') |
| 69 |
} |
| 70 |
case "Topics": |
| 71 |
if in.IsNull() { |
| 72 |
in.Skip() |
| 73 |
out.Topics = nil |
| 74 |
} else { |
| 75 |
if out.Topics == nil { |
| 76 |
out.Topics = new(DSTopicsList) |
| 77 |
} |
| 78 |
easyjsonD519278DecodeBenchmark2(in, out.Topics) |
| 79 |
} |
| 80 |
default: |
| 81 |
in.SkipRecursive() |
| 82 |
} |
| 83 |
in.WantComma() |
| 84 |
} |
| 85 |
in.Delim('}') |
| 86 |
if isTopLevel { |
| 87 |
in.Consumed() |
| 88 |
} |
| 89 |
} |
| 90 |
func easyjsonD519278EncodeBenchmark(out *jwriter.Writer, in LargePayloadEasyJson) { |
| 91 |
out.RawByte('{') |
| 92 |
first := true |
| 93 |
_ = first |
| 94 |
{ |
| 95 |
const prefix string = ",\"Users\":" |
| 96 |
if first { |
| 97 |
first = false |
| 98 |
out.RawString(prefix[1:]) |
| 99 |
} else { |
| 100 |
out.RawString(prefix) |
| 101 |
} |
| 102 |
if in.Users == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { |
| 103 |
out.RawString("null") |
| 104 |
} else { |
| 105 |
out.RawByte('[') |
| 106 |
for v2, v3 := range in.Users { |
| 107 |
if v2 > 0 { |
| 108 |
out.RawByte(',') |
| 109 |
} |
| 110 |
if v3 == nil { |
| 111 |
out.RawString("null") |
| 112 |
} else { |
| 113 |
easyjsonD519278EncodeBenchmark1(out, *v3) |
| 114 |
} |
| 115 |
} |
| 116 |
out.RawByte(']') |
| 117 |
} |
| 118 |
} |
| 119 |
{ |
| 120 |
const prefix string = ",\"Topics\":" |
| 121 |
if first { |
| 122 |
first = false |
| 123 |
out.RawString(prefix[1:]) |
| 124 |
} else { |
| 125 |
out.RawString(prefix) |
| 126 |
} |
| 127 |
if in.Topics == nil { |
| 128 |
out.RawString("null") |
| 129 |
} else { |
| 130 |
easyjsonD519278EncodeBenchmark2(out, *in.Topics) |
| 131 |
} |
| 132 |
} |
| 133 |
out.RawByte('}') |
| 134 |
} |
| 135 |
|
| 136 |
// MarshalJSON supports json.Marshaler interface |
| 137 |
func (v LargePayloadEasyJson) MarshalJSON() ([]byte, error) { |
| 138 |
w := jwriter.Writer{} |
| 139 |
easyjsonD519278EncodeBenchmark(&w, v) |
| 140 |
return w.Buffer.BuildBytes(), w.Error |
| 141 |
} |
| 142 |
|
| 143 |
// MarshalEasyJSON supports easyjson.Marshaler interface |
| 144 |
func (v LargePayloadEasyJson) MarshalEasyJSON(w *jwriter.Writer) { |
| 145 |
easyjsonD519278EncodeBenchmark(w, v) |
| 146 |
} |
| 147 |
|
| 148 |
// UnmarshalJSON supports json.Unmarshaler interface |
| 149 |
func (v *LargePayloadEasyJson) UnmarshalJSON(data []byte) error { |
| 150 |
r := jlexer.Lexer{Data: data} |
| 151 |
easyjsonD519278DecodeBenchmark(&r, v) |
| 152 |
return r.Error() |
| 153 |
} |
| 154 |
|
| 155 |
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface |
| 156 |
func (v *LargePayloadEasyJson) UnmarshalEasyJSON(l *jlexer.Lexer) { |
| 157 |
easyjsonD519278DecodeBenchmark(l, v) |
| 158 |
} |
| 159 |
func easyjsonD519278DecodeBenchmark2(in *jlexer.Lexer, out *DSTopicsList) { |
| 160 |
isTopLevel := in.IsStart() |
| 161 |
if in.IsNull() { |
| 162 |
if isTopLevel { |
| 163 |
in.Consumed() |
| 164 |
} |
| 165 |
in.Skip() |
| 166 |
return |
| 167 |
} |
| 168 |
in.Delim('{') |
| 169 |
for !in.IsDelim('}') { |
| 170 |
key := in.UnsafeString() |
| 171 |
in.WantColon() |
| 172 |
if in.IsNull() { |
| 173 |
in.Skip() |
| 174 |
in.WantComma() |
| 175 |
continue |
| 176 |
} |
| 177 |
switch key { |
| 178 |
case "Topics": |
| 179 |
if in.IsNull() { |
| 180 |
in.Skip() |
| 181 |
out.Topics = nil |
| 182 |
} else { |
| 183 |
in.Delim('[') |
| 184 |
if out.Topics == nil { |
| 185 |
if !in.IsDelim(']') { |
| 186 |
out.Topics = make(DSTopics, 0, 8) |
| 187 |
} else { |
| 188 |
out.Topics = DSTopics{} |
| 189 |
} |
| 190 |
} else { |
| 191 |
out.Topics = (out.Topics)[:0] |
| 192 |
} |
| 193 |
for !in.IsDelim(']') { |
| 194 |
var v4 *DSTopic |
| 195 |
if in.IsNull() { |
| 196 |
in.Skip() |
| 197 |
v4 = nil |
| 198 |
} else { |
| 199 |
if v4 == nil { |
| 200 |
v4 = new(DSTopic) |
| 201 |
} |
| 202 |
easyjsonD519278DecodeBenchmark3(in, v4) |
| 203 |
} |
| 204 |
out.Topics = append(out.Topics, v4) |
| 205 |
in.WantComma() |
| 206 |
} |
| 207 |
in.Delim(']') |
| 208 |
} |
| 209 |
case "MoreTopicsUrl": |
| 210 |
out.MoreTopicsUrl = string(in.String()) |
| 211 |
default: |
| 212 |
in.SkipRecursive() |
| 213 |
} |
| 214 |
in.WantComma() |
| 215 |
} |
| 216 |
in.Delim('}') |
| 217 |
if isTopLevel { |
| 218 |
in.Consumed() |
| 219 |
} |
| 220 |
} |
| 221 |
func easyjsonD519278EncodeBenchmark2(out *jwriter.Writer, in DSTopicsList) { |
| 222 |
out.RawByte('{') |
| 223 |
first := true |
| 224 |
_ = first |
| 225 |
{ |
| 226 |
const prefix string = ",\"Topics\":" |
| 227 |
if first { |
| 228 |
first = false |
| 229 |
out.RawString(prefix[1:]) |
| 230 |
} else { |
| 231 |
out.RawString(prefix) |
| 232 |
} |
| 233 |
if in.Topics == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { |
| 234 |
out.RawString("null") |
| 235 |
} else { |
| 236 |
out.RawByte('[') |
| 237 |
for v5, v6 := range in.Topics { |
| 238 |
if v5 > 0 { |
| 239 |
out.RawByte(',') |
| 240 |
} |
| 241 |
if v6 == nil { |
| 242 |
out.RawString("null") |
| 243 |
} else { |
| 244 |
easyjsonD519278EncodeBenchmark3(out, *v6) |
| 245 |
} |
| 246 |
} |
| 247 |
out.RawByte(']') |
| 248 |
} |
| 249 |
} |
| 250 |
{ |
| 251 |
const prefix string = ",\"MoreTopicsUrl\":" |
| 252 |
if first { |
| 253 |
first = false |
| 254 |
out.RawString(prefix[1:]) |
| 255 |
} else { |
| 256 |
out.RawString(prefix) |
| 257 |
} |
| 258 |
out.String(string(in.MoreTopicsUrl)) |
| 259 |
} |
| 260 |
out.RawByte('}') |
| 261 |
} |
| 262 |
func easyjsonD519278DecodeBenchmark3(in *jlexer.Lexer, out *DSTopic) { |
| 263 |
isTopLevel := in.IsStart() |
| 264 |
if in.IsNull() { |
| 265 |
if isTopLevel { |
| 266 |
in.Consumed() |
| 267 |
} |
| 268 |
in.Skip() |
| 269 |
return |
| 270 |
} |
| 271 |
in.Delim('{') |
| 272 |
for !in.IsDelim('}') { |
| 273 |
key := in.UnsafeString() |
| 274 |
in.WantColon() |
| 275 |
if in.IsNull() { |
| 276 |
in.Skip() |
| 277 |
in.WantComma() |
| 278 |
continue |
| 279 |
} |
| 280 |
switch key { |
| 281 |
case "Id": |
| 282 |
out.Id = int(in.Int()) |
| 283 |
case "Slug": |
| 284 |
out.Slug = string(in.String()) |
| 285 |
default: |
| 286 |
in.SkipRecursive() |
| 287 |
} |
| 288 |
in.WantComma() |
| 289 |
} |
| 290 |
in.Delim('}') |
| 291 |
if isTopLevel { |
| 292 |
in.Consumed() |
| 293 |
} |
| 294 |
} |
| 295 |
func easyjsonD519278EncodeBenchmark3(out *jwriter.Writer, in DSTopic) { |
| 296 |
out.RawByte('{') |
| 297 |
first := true |
| 298 |
_ = first |
| 299 |
{ |
| 300 |
const prefix string = ",\"Id\":" |
| 301 |
if first { |
| 302 |
first = false |
| 303 |
out.RawString(prefix[1:]) |
| 304 |
} else { |
| 305 |
out.RawString(prefix) |
| 306 |
} |
| 307 |
out.Int(int(in.Id)) |
| 308 |
} |
| 309 |
{ |
| 310 |
const prefix string = ",\"Slug\":" |
| 311 |
if first { |
| 312 |
first = false |
| 313 |
out.RawString(prefix[1:]) |
| 314 |
} else { |
| 315 |
out.RawString(prefix) |
| 316 |
} |
| 317 |
out.String(string(in.Slug)) |
| 318 |
} |
| 319 |
out.RawByte('}') |
| 320 |
} |
| 321 |
func easyjsonD519278DecodeBenchmark1(in *jlexer.Lexer, out *DSUser) { |
| 322 |
isTopLevel := in.IsStart() |
| 323 |
if in.IsNull() { |
| 324 |
if isTopLevel { |
| 325 |
in.Consumed() |
| 326 |
} |
| 327 |
in.Skip() |
| 328 |
return |
| 329 |
} |
| 330 |
in.Delim('{') |
| 331 |
for !in.IsDelim('}') { |
| 332 |
key := in.UnsafeString() |
| 333 |
in.WantColon() |
| 334 |
if in.IsNull() { |
| 335 |
in.Skip() |
| 336 |
in.WantComma() |
| 337 |
continue |
| 338 |
} |
| 339 |
switch key { |
| 340 |
case "Username": |
| 341 |
out.Username = string(in.String()) |
| 342 |
default: |
| 343 |
in.SkipRecursive() |
| 344 |
} |
| 345 |
in.WantComma() |
| 346 |
} |
| 347 |
in.Delim('}') |
| 348 |
if isTopLevel { |
| 349 |
in.Consumed() |
| 350 |
} |
| 351 |
} |
| 352 |
func easyjsonD519278EncodeBenchmark1(out *jwriter.Writer, in DSUser) { |
| 353 |
out.RawByte('{') |
| 354 |
first := true |
| 355 |
_ = first |
| 356 |
{ |
| 357 |
const prefix string = ",\"Username\":" |
| 358 |
if first { |
| 359 |
first = false |
| 360 |
out.RawString(prefix[1:]) |
| 361 |
} else { |
| 362 |
out.RawString(prefix) |
| 363 |
} |
| 364 |
out.String(string(in.Username)) |
| 365 |
} |
| 366 |
out.RawByte('}') |
| 367 |
} |