| 49 | // REQUIRES: dst has enough space for the value being written |
| 50 | |
| 51 | inline void EncodeFixed32(char *dst, uint32_t value) { |
| 52 | uint8_t *const buffer = reinterpret_cast<uint8_t *>(dst); |
| 53 | |
| 54 | // Recent clang and gcc optimize this to a single mov / str instruction. |
| 55 | buffer[0] = static_cast<uint8_t>(value); |
| 56 | buffer[1] = static_cast<uint8_t>(value >> 8); |
| 57 | buffer[2] = static_cast<uint8_t>(value >> 16); |
| 58 | buffer[3] = static_cast<uint8_t>(value >> 24); |
| 59 | } |
| 60 | |
| 61 | inline void EncodeFixed64(char *dst, uint64_t value) { |
| 62 | uint8_t *const buffer = reinterpret_cast<uint8_t *>(dst); |