(num: i64, buffer: &mut [u8; 16])
| 132 | |
| 133 | #[inline] |
| 134 | fn hex_int64(num: i64, buffer: &mut [u8; 16]) -> &[u8] { |
| 135 | if num == 0 { |
| 136 | return b"0"; |
| 137 | } |
| 138 | |
| 139 | // Walk the value two nibbles (one full byte) at a time. The buffer is |
| 140 | // filled from the right so the high-order nibbles end up first; the |
| 141 | // returned slice trims leading zeros automatically. |
| 142 | let mut n = num as u64; |
| 143 | let mut i = 16; |
| 144 | while n >= 0x10 { |
| 145 | i -= 2; |
| 146 | let pair = HEX_LOOKUP_UPPER[(n & 0xFF) as usize]; |
| 147 | buffer[i] = pair[0]; |
| 148 | buffer[i + 1] = pair[1]; |
| 149 | n >>= 8; |
| 150 | } |
| 151 | if n > 0 { |
| 152 | // Single remaining high nibble (value 0x1..=0xF). |
| 153 | i -= 1; |
| 154 | buffer[i] = HEX_CHARS_UPPER_NIBBLES[n as usize]; |
| 155 | } |
| 156 | &buffer[i..] |
| 157 | } |
| 158 | |
| 159 | /// Generic hex encoding for byte array types |
| 160 | fn hex_encode_bytes<'a, I, T>( |
no outgoing calls
searching dependent graphs…