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

Function encodeVarExpNumber

pkg/util/encoding/decimal.go:179–201  ·  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

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