MCPcopy Index your code
hub / github.com/tinylib/msgp / AppendInt64

Function AppendInt64

msgp/write_bytes.go:95–134  ·  view source on GitHub ↗

AppendInt64 appends an int64 to the slice

(b []byte, i int64)

Source from the content-addressed store, hash-verified

93
94// AppendInt64 appends an int64 to the slice
95func AppendInt64(b []byte, i int64) []byte {
96 if i >= 0 {
97 switch {
98 case i <= math.MaxInt8:
99 return append(b, wfixint(uint8(i)))
100 case i <= math.MaxInt16:
101 o, n := ensure(b, 3)
102 putMint16(o[n:], int16(i))
103 return o
104 case i <= math.MaxInt32:
105 o, n := ensure(b, 5)
106 putMint32(o[n:], int32(i))
107 return o
108 default:
109 o, n := ensure(b, 9)
110 putMint64(o[n:], i)
111 return o
112 }
113 }
114 switch {
115 case i >= -32:
116 return append(b, wnfixint(int8(i)))
117 case i >= math.MinInt8:
118 o, n := ensure(b, 2)
119 putMint8(o[n:], int8(i))
120 return o
121 case i >= math.MinInt16:
122 o, n := ensure(b, 3)
123 putMint16(o[n:], int16(i))
124 return o
125 case i >= math.MinInt32:
126 o, n := ensure(b, 5)
127 putMint32(o[n:], int32(i))
128 return o
129 default:
130 o, n := ensure(b, 9)
131 putMint64(o[n:], i)
132 return o
133 }
134}
135
136// AppendInt appends an int to the slice
137func AppendInt(b []byte, i int) []byte { return AppendInt64(b, int64(i)) }

Callers 15

MarshalMsgMethod · 0.92
MarshalMsgMethod · 0.92
MarshalMsgMethod · 0.85
BenchmarkReadInt64Function · 0.85
AppendDurationFunction · 0.85
AppendIntFunction · 0.85
AppendInt8Function · 0.85
AppendInt16Function · 0.85
AppendInt32Function · 0.85
AppendIntfFunction · 0.85
AppendJSONNumberFunction · 0.85

Calls 7

wfixintFunction · 0.85
putMint16Function · 0.85
putMint32Function · 0.85
putMint64Function · 0.85
wnfixintFunction · 0.85
putMint8Function · 0.85
ensureFunction · 0.70

Tested by 6

BenchmarkReadInt64Function · 0.68
TestIssue116Function · 0.68
TestAppendInt64Function · 0.68
BenchmarkAppendInt64Function · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…