getNextSize returns the size of the next object on the wire. returns (obj size, obj elements, error) only maps and arrays have non-zero obj elements for maps and arrays, obj size does not include elements use uintptr b/c it's guaranteed to be large enough to hold whatever we can fit in memory.
(r *fwd.Reader)
| 335 | // use uintptr b/c it's guaranteed to be large enough |
| 336 | // to hold whatever we can fit in memory. |
| 337 | func getNextSize(r *fwd.Reader) (uintptr, uintptr, error) { |
| 338 | lead, err := r.PeekByte() |
| 339 | if err != nil { |
| 340 | return 0, 0, err |
| 341 | } |
| 342 | spec := getBytespec(lead) |
| 343 | size, mode := spec.size, spec.extra |
| 344 | if size == 0 { |
| 345 | return 0, 0, InvalidPrefixError(lead) |
| 346 | } |
| 347 | if mode >= 0 { |
| 348 | return uintptr(size), uintptr(mode), nil |
| 349 | } |
| 350 | b, err := r.Peek(int(size)) |
| 351 | if err != nil { |
| 352 | return 0, 0, err |
| 353 | } |
| 354 | switch mode { |
| 355 | case extra8: |
| 356 | return uintptr(size) + uintptr(b[1]), 0, nil |
| 357 | case extra16: |
| 358 | return uintptr(size) + uintptr(big.Uint16(b[1:])), 0, nil |
| 359 | case extra32: |
| 360 | return uintptr(size) + uintptr(big.Uint32(b[1:])), 0, nil |
| 361 | case map16v: |
| 362 | return uintptr(size), 2 * uintptr(big.Uint16(b[1:])), nil |
| 363 | case map32v: |
| 364 | return uintptr(size), 2 * uintptr(big.Uint32(b[1:])), nil |
| 365 | case array16v: |
| 366 | return uintptr(size), uintptr(big.Uint16(b[1:])), nil |
| 367 | case array32v: |
| 368 | return uintptr(size), uintptr(big.Uint32(b[1:])), nil |
| 369 | default: |
| 370 | return 0, 0, fatal |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | // Skip skips over the next object, regardless of |
| 375 | // its type. If it is an array or map, the whole array |
no test coverage detected
searching dependent graphs…