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)
| 177 | // |
| 178 | // Returns the length-adjusted buffer. |
| 179 | func 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. |
no test coverage detected
searching dependent graphs…