MCPcopy
hub / github.com/tinylib/msgp / ReadInt64Bytes

Function ReadInt64Bytes

msgp/read_bytes.go:424–524  ·  view source on GitHub ↗

ReadInt64Bytes tries to read an int64 from 'b' and return the value and the remaining bytes. Possible errors: - [ErrShortBytes] (too few bytes) - [TypeError] (not a int)

(b []byte)

Source from the content-addressed store, hash-verified

422// - [ErrShortBytes] (too few bytes)
423// - [TypeError] (not a int)
424func ReadInt64Bytes(b []byte) (i int64, o []byte, err error) {
425 if len(b) < 1 {
426 return 0, nil, ErrShortBytes
427 }
428
429 lead := b[0]
430 b = b[1:]
431 if isfixint(lead) {
432 i = int64(rfixint(lead))
433 o = b
434 return
435 }
436 if isnfixint(lead) {
437 i = int64(rnfixint(lead))
438 o = b
439 return
440 }
441
442 switch lead {
443 case mint8:
444 if len(b) < 1 {
445 err = ErrShortBytes
446 return
447 }
448 i = int64(int8(b[0]))
449 o = b[1:]
450 return
451
452 case muint8:
453 if len(b) < 1 {
454 err = ErrShortBytes
455 return
456 }
457 i = int64(b[0])
458 o = b[1:]
459 return
460
461 case mint16:
462 if len(b) < 2 {
463 err = ErrShortBytes
464 return
465 }
466 i = int64(int16(big.Uint16(b)))
467 o = b[2:]
468 return
469
470 case muint16:
471 if len(b) < 2 {
472 err = ErrShortBytes
473 return
474 }
475 i = int64(big.Uint16(b))
476 o = b[2:]
477 return
478
479 case mint32:
480 if len(b) < 4 {
481 err = ErrShortBytes

Callers 15

UnmarshalMsgMethod · 0.92
UnmarshalMsgMethod · 0.92
TestReadInt64BytesFunction · 0.85
UnmarshalMsgMethod · 0.85
FuzzReadBytesFunction · 0.85
rwMapKeyBytesFunction · 0.85
rwIntBytesFunction · 0.85
TestIssue116Function · 0.85
ReadDurationBytesFunction · 0.85
ReadInt32BytesFunction · 0.85
ReadInt16BytesFunction · 0.85

Calls 5

isfixintFunction · 0.85
rfixintFunction · 0.85
isnfixintFunction · 0.85
rnfixintFunction · 0.85
badPrefixFunction · 0.85

Tested by 4

TestReadInt64BytesFunction · 0.68
FuzzReadBytesFunction · 0.68
TestIssue116Function · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…