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

Method WriteInt64

msgp/write.go:379–404  ·  view source on GitHub ↗

WriteInt64 writes an int64 to the writer

(i int64)

Source from the content-addressed store, hash-verified

377
378// WriteInt64 writes an int64 to the writer
379func (mw *Writer) WriteInt64(i int64) error {
380 if i >= 0 {
381 switch {
382 case i <= math.MaxInt8:
383 return mw.push(wfixint(uint8(i)))
384 case i <= math.MaxInt16:
385 return mw.prefix16(mint16, uint16(i))
386 case i <= math.MaxInt32:
387 return mw.prefix32(mint32, uint32(i))
388 default:
389 return mw.prefix64(mint64, uint64(i))
390 }
391 }
392 switch {
393 case i >= -32:
394 return mw.push(wnfixint(int8(i)))
395 case i >= math.MinInt8:
396 return mw.prefix8(mint8, uint8(i))
397 case i >= math.MinInt16:
398 return mw.prefix16(mint16, uint16(i))
399 case i >= math.MinInt32:
400 return mw.prefix32(mint32, uint32(i))
401 default:
402 return mw.prefix64(mint64, uint64(i))
403 }
404}
405
406// WriteInt8 writes an int8 to the writer
407func (mw *Writer) WriteInt8(i int8) error { return mw.WriteInt64(int64(i)) }

Callers 15

TestReadInt64BytesFunction · 0.95
TestReadUint64BytesFunction · 0.95
TestReadInt64Function · 0.95
TestReadIntOverflowsFunction · 0.95
TestSkipFunction · 0.95
TestWriteInt64Function · 0.95
BenchmarkWriteInt64Function · 0.95
TestCopyJSONFunction · 0.95
BenchmarkCopyToJSONFunction · 0.95

Calls 7

pushMethod · 0.95
prefix16Method · 0.95
prefix32Method · 0.95
prefix64Method · 0.95
prefix8Method · 0.95
wfixintFunction · 0.85
wnfixintFunction · 0.85

Tested by 15

TestReadInt64BytesFunction · 0.76
TestReadUint64BytesFunction · 0.76
TestReadInt64Function · 0.76
TestReadIntOverflowsFunction · 0.76
TestSkipFunction · 0.76
TestWriteInt64Function · 0.76
BenchmarkWriteInt64Function · 0.76
TestCopyJSONFunction · 0.76
BenchmarkCopyToJSONFunction · 0.76