| 27 | // without any bounds checking. |
| 28 | |
| 29 | inline uint16 DecodeFixed16(const char* ptr) { |
| 30 | if (port::kLittleEndian) { |
| 31 | // Load the raw bytes |
| 32 | uint16 result; |
| 33 | memcpy(&result, ptr, sizeof(result)); // gcc optimizes this to a plain load |
| 34 | return result; |
| 35 | } else { |
| 36 | return ((static_cast<uint16>(static_cast<unsigned char>(ptr[0]))) | |
| 37 | (static_cast<uint16>(static_cast<unsigned char>(ptr[1])) << 8)); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | inline uint32 DecodeFixed32(const char* ptr) { |
| 42 | if (port::kLittleEndian) { |