encodeEandM encodes the exponent and mantissa, appending the encoding to a byte buffer. The mantissa m can be stored in the spare capacity of appendTo.
(appendTo []byte, negative bool, e int, m []byte)
| 151 | // |
| 152 | // The mantissa m can be stored in the spare capacity of appendTo. |
| 153 | func encodeEandM(appendTo []byte, negative bool, e int, m []byte) []byte { |
| 154 | var buf []byte |
| 155 | if n := len(m) + maxVarintSize + 2; n <= cap(appendTo)-len(appendTo) { |
| 156 | buf = appendTo[len(appendTo) : len(appendTo)+n] |
| 157 | } else { |
| 158 | buf = make([]byte, n) |
| 159 | } |
| 160 | switch { |
| 161 | case e < 0: |
| 162 | return append(appendTo, encodeSmallNumber(negative, e, m, buf)...) |
| 163 | case e >= 0 && e <= 10: |
| 164 | return append(appendTo, encodeMediumNumber(negative, e, m, buf)...) |
| 165 | case e >= 11: |
| 166 | return append(appendTo, encodeLargeNumber(negative, e, m, buf)...) |
| 167 | } |
| 168 | panic("unreachable") |
| 169 | } |
| 170 | |
| 171 | // encodeVarExpNumber encodes a Uvarint exponent and mantissa into a buffer; |
| 172 | // only used for small (less than 0) and large (greater than 10) exponents. |
no test coverage detected
searching dependent graphs…