MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / encodeVarExpNumber

Function encodeVarExpNumber

pkg/util/encoding/decimal.go:174–196  ·  view source on GitHub ↗

encodeVarExpNumber encodes a Uvarint exponent and mantissa into a buffer; only used for small (less than 0) and large (greater than 10) exponents. If required, the mantissa should already be in ones complement. The encoding must fit in encInto. The mantissa m can overlap with encInto. Returns the

(tag byte, expAscending bool, exp uint64, m []byte, encInto []byte)

Source from the content-addressed store, hash-verified

172//
173// Returns the length-adjusted buffer.
174func encodeVarExpNumber(tag byte, expAscending bool, exp uint64, m []byte, encInto []byte) []byte {
175 // Because m can overlap with encInto, we must first copy m to the right place
176 // before modifying encInto.
177 var n int
178 if expAscending {
179 n = EncLenUvarintAscending(exp)
180 } else {
181 n = EncLenUvarintDescending(exp)
182 }
183 l := 1 + n + len(m)
184 if len(encInto) < l+1 {
185 panic("buffer too short")
186 }
187 copy(encInto[1+n:], m)
188 encInto[0] = tag
189 if expAscending {
190 EncodeUvarintAscending(encInto[1:1], exp)
191 } else {
192 EncodeUvarintDescending(encInto[1:1], exp)
193 }
194 encInto[l] = decimalTerminator
195 return encInto[:l+1]
196}
197
198// encodeSmallNumber encodes the exponent and mantissa into a buffer; only used
199// when the exponent is negative. See encodeVarExpNumber.

Callers 2

encodeSmallNumberFunction · 0.85
encodeLargeNumberFunction · 0.85

Calls 4

EncLenUvarintAscendingFunction · 0.85
EncLenUvarintDescendingFunction · 0.85
EncodeUvarintAscendingFunction · 0.85
EncodeUvarintDescendingFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…